我有一个这样的模型,
[Table("Clientaccessories")]
public class Clientaccessory
{
public Clientaccessory()
{
LastModifiedDateTime = DateTime.UtcNow;
}
public string accessoryId { get; set; }
public Guid ClientReference { get; set; }
public DateTime LastModifiedDateTime { get; set; }
public bool Isactive { get; set; }
public virtual accessory accessory { get; set; }
}
我在存储库方法中有此代码
public IEnumerable<Clientaccessory> getclientaccessories(Guid ClientReference)
{
var _context = new DBContext();
var results = from a in _context.accessories
join ca in _context.Clientaccessories
on new { accessoryId = a.Id,ClientReference = new Guid(ClientReference) }
equals new { ca.accessoryId,ca.ClientReference } into ca_join
from ca in ca_join.DefaultIfEmpty()
where
ca.Isactive == true ||
ca.Isactive == null
select new {};
}
现在的问题是,即使它是一个虚拟属性,我也不知道如何一起返回Clientaccessory和accessory对象。
也可以在一个存储库中调用2个实体,还是应该返回IQueryable并在域服务类中进行操作?谢谢。
我不想放平这样的值,
select new {
Id = a.Id,ClientReference = ca.ClientReference
and so on...
};