The thing is that I’ve a Odata service with a default configuration:
public class Service : DataService<SummumnetFilterContext>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
protected override SummumnetFilterContext CreateDataSource()
{
var dataSource = new SummumnetFilterContext();
dataSource.Configuration.ProxyCreationEnabled = false;
return dataSource;
}
}
And a couple of tables with this structure:
public class LabTest
{
public int ID { get; set; }
public DateTime ApplicationDate { get; set; }
public DateTime ReportDate { get; set; }
public virtual List<LabValue> LabValue { get; set; }
}
public class LabValue
{
[Required]
public int ID { get; set; }
public string Value { get; set; }
public string Units { get; set; }
public int LabTestID { get; set; }
public virtual LabTest LabTest { get; set; }
}
The thing is, that when I’m trying to retrive any LabTest, with it’s LabValue, using Odata the List<LabValue> LabValues comes empty every time, not null, but empty. Can any one help me with this?. At my service y use EF ofcourse.
I guess you are using WCF Data Services to consume your OData feed. In such case you must tell the service that you want your relation to be loaded together with the main entity:
If you call the data service manually through URL you must use
expandquery option.To make it clear – there is no transparent lazy loading for the service. Lazy loading is EF feature used when you work directly with the entity on the same tier in scope of current EF context. When you consume OData feed you are most probably not on the same tier (even machine) and transparent lazy loading is not offered to avoid additional network roundtrips to the service.