Many-to-many sorting in Entity Framework -
In my application there is a unit framework model that has many relation-to-many relationships, such as the following:
Product Group: Scalar: ID, Name Navigation: Product Group Product: Scalar: Id, Sku, Details, etc. Navigation: Product group Product product group: Scaler: Product group IID, Product ID, Position Navigation: Product, Product group
Note that the intermediate table has a scalar property called status, In which the product should be displayed within the product group.
How would you write a LINQ query, which is a list of products sorted by the position property in a given product group? If I am writing good ol 'sql, then I will write something like this:
but I can not understand LINQ.
Um, your SQL will not work, because no ProductGroup.Position
< / P>
but I think you want:
var q = reference from pgp. Product group products where pgp.ProductGroup.Id == ID select pgp.Position pgp.Product by order;
Comments
Post a Comment