asp.net - Strongly typed access to result-set from Linq Join - to display in MVC view -
I'm new to MVC / Linq party (coming from Java).
I know that I can use some of the following to type emphatically, but do I want to use joining my linq query?
Public Zero IQueryable & lt; Products & gt; GetItems (int CategoryID)
{... linq query ...} Enter code
Should help with some of the following (estimating property names; DB is your data reference):
public IQueryable & lt; Products & gt; GetItems (int category id) {returns db.Products.Where (P = & gt; p.Category.CategoryID == Category ID). Enqueueable (); }
Or if you are not comfortable with the Lambda syntax, the following is synonymous:
Public IQueryable & lt; Products & gt; GetItems (int rangeID) {var results = p in db.Products where p.Category.CategoryID == select Category ID; Return Results. Enqueueable (); }
The product category has class property, which provides firmly typed access to all the properties in that category. For example, to get the name of the category, you will use something like a product. Category.
In addition, there are plenty of good linqs for SQL tutorials. Try the following:
Comments
Post a Comment