EF DbContext와 함께 WCF Data Services 5.0을 사용하고 있습니다.WCF Data Services 5.0 + DbContext : 관련 엔터티를 반환하는 방법?
확장 및 LoadProperty를 사용하여 한 요청에서 관련 엔터티를 반환하도록 WCF를 가져올 수 있다고 말하는 기존 기사를 참조하십시오.
DbContext에서 볼 수있는 유일한 기능은 포함이지만 작동하지 않는 것입니다.
DbContext로 작업 할 때 관련된 모든 레코드를로드 할 수있는 방법이 있습니까?
나는 (많은 종류의 개체를 포함 할 수 있습니다 하나 CategoryGroup) 아래의 코드를 사용하고 있습니다 :
는[WebGet]
public IQueryable<CategoryGroup> GetAllCategories(string activationCode)
{
try
{
var db = this.CurrentDataSource;
var licence = db.Licenses
.Include("Contact")
.FirstOrDefault();
if (licence != null)
{
var customerId = licence.Contact.CustomerId;
return db.CategoryGroups.Include("Categories").Where(r => r.CustomerId == customerId);
}
}
catch(Exception ex)
{
}
return new List<CategoryGroup>().AsQueryable();
}
이 기능은 하나로, OData 형식 (관련 카테고리 엔티티 제외) CategoryGroup 개체를 반환합니다.