asp.net mvc - Linq select from list -
I can not understand this, I am not new to the MVC model, but maybe my brain is just tired. Public category categories as a list of public sector (cihCategoryOrgDef) cihCategoryOrgDef public property as the public property category, this name as the string public sub
See model CategoriesController When I run it, give me the I use a single Since If your query can return more than one result and you only want to get the first result , Then use Class = from x .... line
gets an object cast exception 'WhereSelectLi To type 'library.cihCateg oryOrgDef, Library.cihCategoryOrgDef]', type 'library.cihCategoryOrgDef'.
category I'm trying to get That's why I might be an editing page for that specific category. Am I doing all this wrong?
class is for the alone category , You need to make sure that your LINQ returns a single result if you are sure that the query returns only one value, then use
SingleOrDefault :
Category = (Select from x to x.codId = codId in x) .SingleOrDefault ()
FirstOrDefault :
category = (In the categories in x where x.codId = codId select x). FirstOrDefault ()
Comments
Post a Comment