Hi,
There is a scenario where we keep some data which should be available to all tenants but in the virtual entity it's coming as null so I suppose it's to do with multi tenancy, what is the way around this.
For example
public class ClassOne : Entity, IMustHaveTenant { public virtual int TenantId { get; set; } public int ClassTwoId {get;set;} [ForeignKey("ClassTwoId")] public virtual ClassTwo {get;set;} }
public class ClassTwo : Entity { }
ClassTwo is coming as null when I access ClassOne although there is a data for the id.
How do I fix this? Plz help
6 Answer(s)
-
0
Hi,
Just remove IMustHaveTenant interface from your Entity.
-
0
No that's the point. ClassOne is IMustHaveTenant and ClassTwo should be accessible to all tenants.
-
0
Hi,
Could you share your query ?
-
0
var query = _classOneRepository.GetAll();
Since GetAllIncluding is only used with collections, it should get virtual with GetAll, right?
-
0
You have to include it into your query;
var query = _classOneRepository.GetAll(); .Include(e => e.ClassTwo);
-
0
Ok thank you very much, it works.