Tuesday, 15 May 2012

c# - Linq, OData and WCF : “the method join is not supported” -


I am trying to retrieve and display data from multiple tables. I have added a mutliple in such a way:

  var prod = In the product from context. Insert in the product is based on ISOD IDIIL in context. Project on Producer PRODUCT_ID is equal to. Providers add a location in the context. Islocated.LOCATION_ID is the same as the location. Location by LOCICATION_ID sequence .LOCATION_ID group new {location_ID = location.LOCATION_ID, product_id = product.PRODUCT_ID} by location. Choose locat new {location_ID = locat.Key, product = location} in LOCCATION_ID;   

This link is working to call OData which is to call from the web service: When I make a simple selection, I am able to recover data. Then, I want to display the data that is in the result. So I have created a dictionary:

  dictionary < String, list & lt; ProductModel & gt; & Gt; Dict = new dictionary & lt; String, list & lt; ProductModel & gt; & Gt; (); Foreach (Priority Place in Prod) {list & lt; ProdctModel & gt; Products = new list & lt; ProductsModel & gt; (); Forchach (var p in locat.Product) {products.Add (new product model (p.Location_ID, p.Product_ID)); } Dict.Add (locat.Location_ID.ToString (), Products); }   

Where product MODEL is a simple class like:

  public class ProdctModel {public int locationID {get; Set;} public int productID {get; Set;} Public ProdctModel (int location_ID, int product_ID) {this.locationID = location_ID; This.productID = product_ID; }}   

But when I'm playing this, I get the following:

  one ???? Joining the method is not supported? ??? Ligne 131: Dictionary & lt; String, list & lt; ProdctModel & gt; & Gt; Dict = new dictionary & lt; String, list & lt; ProdctModel & gt; & Gt; (); Ligne 132: Forchha (Prod in different locations) {  

How to solve it? I method involves instead .Expand (saw a couple of conditions using) but I do not know how to use it:?! You can help me

thanks

I never used OData with LINQ But im thinking you can not include various remote resources. Try to get the object memory first, and then join it:

  var products = context.PRODUCT.ToList (); Var islocateds = context.ISAUDITEDIN.ToList (); Var place = context.likation.ToList (); Var prod = products is equal to join in places islocated islocated.PRODUCT_ID islocated.LOCATION_ID in islocateds on product.PRODUCT_ID join the product in location.LOCATION_ID orderby location.LOCATION_ID group new {Location_ID = location.LOCATION_ID, Product_id = product.PRODUCT_ID} by location Select location in new LOCCATION_ID {location_ID = locat.Key, product = location};   

Remember that it will download all 3 tables.

Edit In addition, when, dictionary making "prod" you are getting exception varialble a IEnumerable- it only executes when you "foreach" or something similar request.

No comments:

Post a Comment