views:

18

answers:

1

Hi All, In my SL Application I have multiple DomainService Classes which deals with the specific entities. Now I need to call upon a method from DomainService Class 1 in Class 2. How do I do that? e.g Product entity is handled in Class2 whereas the Workflow entities are handled by Class 1. I have created a custom class which has properties from entities. Now I need to access the WorkflowStatus fields from one of Workflow entities for the relevant product in Class 2.

How can I call the Class1 method (GetLatestStatus(int productID)) from Class2's method GetProudctwithStatus()

 public IList<ProductVS> GetProductsWithStatus()
    {

        var result =  (from p in this.ObjectContext.Products
                        select new ProductVS
                         {
                            ProductID = p.ProductID,
                            Code = p.Code,

                                // ???
                            WFStatus = **Class1.GetLatestStatus(p.ProductID)**

                         }).ToList();

        return result;
    }

Any response would be much appreciated

A: 

If this is a common task I would instead create an operation on the Server which returned the data that you need. You can do this by creating the method and utilizing the [Invoke] attribute.

Otherwise you need to call two methods, both of which are asynchronous. If this was my project I would make the first call, then send a list of ProductID's to the server to retrieve the WorkFlow status. Otherwise you would be making N number of service calls to the server (one per each entity returned from the server) which is bad.

Joe McBride