Hi. I m using a Invoke Operation which return a class "Product"
public Product GetProductById(int Id)
{
Product Record = this.ObjectContext.Product.Include("Order_Detail").Where(d=>d.ProductID=Id).FirstOrDefault()
return Record;
}
But i m not able to get Order_Detail in the the completed event of the class
InvokeOperation<Product> Invk = ObjProduct.GetProductById();
Invk.Completed += (sender, e) =>
{
if (!Invk.HasError)
{
Product ObjProduct = Invk.Value;
Order objorder=ObjProduct.Order_Detail;
}
};
i m getting ObjProduct.Order_Detail as Null i not known why i m not able to include Order_Detail in this Product entity
I have written [Include] in metadata as well
[Include]
public Order Order { get; set; }
But Still i m not able to get Order_Detail In the collection. Waiting for a positive response.
This is the expected behavior. Invokes are meant to execute an operation on the server or retrieve a simple object.
As you can see, the InvokeOperation callback don't contains the usual Entities/AllEntities properties that make room for Included Entities.
I suggest you to use a standard load operation with a parameter to get your data.
public IQueryable<Product> GetProductById(int Id)
{
return this.ObjectContext.Product.Include("Order_Detail").Where(d=>d.ProductID=Id);
}
If what you're trying to achieve is "Non Accumulating Execution" (i.e. don't load your domainContext's entityContainer with the result of the query) than have a look at this post from Mathew Charles