Я создал класс dataservice WCF для возврата результатов запроса клиенту javascript.Вот псевдокод для моего dataservice:
public class MyDataService : DataService<MyEntities>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("MyGetMethod", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServicePRotocolVersion.V2;
}
[WebGet(UriTemplate = "{SomeID}"]
public IEnumerable<Models.Customer> MyGetMethod(int? someID)
{
if (someID == null) throw new DataServiceException("ID not specified");
MyEntities context = this.CurrentDataSource;
context.ContextOptions.LazyLoadingEnabled = false;
var q = Linq statement which queries for a collection of entities from context
IEnumerable<Models.Customer> result = q;
foreach (Models.Customer customer in result)
{
if (!customer.Contacts.IsLoaded)
customer.Contacts.Load();
}
return result;
}
}
Вызов от клиента требует результата в json.Когда я отлаживаю метод get в dataservice, в результате есть конкретные связанные данные, раскрытые в свойстве WrappedRelatedEntities, но в json, возвращаемом клиенту, для этой связанной сущности он сказал отложенный.
Что мне нужносделать, чтобы эти связанные объекты были возвращены клиенту?Спасибо!