Entity Framework is a unit type of product generated by I wrote this question
Public IQueryable & lt; Products & gt; Return to P in GetProducts (Int CategarioId) {DB.Products, where p.CategoryID == selects IDID new product {name = p.Name}; } throws the following error in the code below:
"The unit or complex type store. LINQ can not be created in the unit query . "
var product = product repository. Gate Products (1) Tolist (); But when I use p using then select new product {name = p.Name}; This works correctly. How do I create a custom selection section?
You should not (and should not be projected on a mapped unit), however, Project on or on:
Public category ProductDTO {public string name {get; Set; } // other fields, you may need it from Product Unit} and your method will return a list of DTOs.
Public List & amp; ProductDTO & gt; GetProducts (Int Categari ID) {Returns (from D in P.Products, where p.CategoryID == class ID is selected new ProductDTO {name = p.Name}). ToList (); }
Comments
Post a Comment