0
相關項目我有兩個對象,如:的EntityFramework獲得通過ID或現場
public class Area : IEntity
{
public virtual int Id { get; set; }
public virtual int AreaTypeLookupId { get; set; }
[Column(TypeName = "varchar")]
[StringLength(100)]
public virtual string Name { get; set; }
[Column(TypeName = "varchar")]
[StringLength(2)]
public virtual string VMRegionCode { get; set; }
public virtual int GISPrimaryKeyId { get; set; }
public virtual string ConcatenatedGISAreaIds { get; set; }
public virtual int? ParentAreaId { get; set; }
public virtual int? ParentRegionAreaId { get; set; }
[Column(TypeName = "char")]
[StringLength(3)]
public virtual string CostCenterCode { get; set; }
[Column(TypeName = "varchar")]
[StringLength(64)]
public string CreatedByUserName { get; set; }
public DateTime CreatedDateTime { get; set; }
[Column(TypeName = "varchar")]
[StringLength(64)]
public string LastModifiedByUserName { get; set; }
public DateTime? LastModifiedDateTime { get; set; }
// Navigation properties
public virtual AreaTypeLookup AreaTypeLookup { get; set; }
}
public class AreaTypeLookup : IEntity
{
[Column("Id")]
public virtual int AreaTypeLookupId { get; set; }
[Column(TypeName = "varchar")]
[StringLength(100)]
public virtual string Name { get; set; }
[Column(TypeName = "varchar")]
[StringLength(10)]
public virtual string ShortName { get; set; }
public virtual int? AreaTypeLevelLookupId { get; set; }
public virtual int? OperationTypeLookupId { get; set; }
public virtual int? ParentAreaTypeLookupId { get; set; }
public bool IsAvailableToSetBudgetAgainst { get; set; }
public int DisplaySortOrder { get; set; }
public bool IsProtected { get; set; }
public DateTime? DeletedDateTime { get; set; }
public int? ManagedByServiceTypeLookupId { get; set; }
[Column(TypeName = "varchar")]
[StringLength(64)]
public string CreatedByUserName { get; set; }
public DateTime CreatedDateTime { get; set; }
[Column(TypeName = "varchar")]
[StringLength(64)]
public string LastModifiedByUserName { get; set; }
public DateTime? LastModifiedDateTime { get; set; }
}
我想要的是讓地方areatypelookupid = 3。對於這個區域鍵入名稱爲「區域」的所有領域
什麼是獲得代碼的可維護性方面的最佳方式:
此:
var areas = _unitOfWork.AreaRepository.GetAll().Where(x => x.AreaTypeLookupId == 3);
或這個:
var areas = _unitOfWork.AreaRepository.GetAll().Where(x => x.AreaTypeLookup.Name == "region");
在那裏我猜「區域」應該從一個資源文件真正成爲。