namespace ET { public readonly struct LSEntityRef where T: LSEntity { private readonly long id; private readonly T entity; private LSEntityRef(T t) { this.id = t.Id; this.entity = t; } private T UnWrap { get { if (this.entity == null) { return null; } if (this.entity.Id != this.id) { return null; } return this.entity; } } public static implicit operator LSEntityRef(T t) { return new LSEntityRef(t); } public static implicit operator T(LSEntityRef v) { return v.UnWrap; } } }