asp.net mvc - Populating a ViewModel from a database model -


I have a ViewModel that inherits a database model. How to populate ViewModel from a database I can not work out "ViewModel"

  public class CustomerView Customer Viewing New LookUpData ReadOnly as inherited in the property OwnerList list (SelectListItem's) received return look.OwnersList (True) end of termination property termination property termination class   

"controller"

  edit function (alternative id = nothing as integer) ActionResult Moderate model is in the form of New CustomerView Model = (from c db.Customers in c.Id = Id andalso c.OrganisationId = s.Or GanisationId). FirstOrDefault then the model is nothing then return the redirectToAction ("list") or else see the return (model) end if the end function   

I get the wrong cast exception.

Any help would be greatly appreciated.

Your Linux query is returning (I think) the customer of the object As a list that you want to project in your visual model object, select a :

  Modal = Change your Linq (c from db.Customers _ Select the new customer view with c. Id = Id and also _ c.OrganisationId = s.OrganisationId _ {.CompanyName = c.CompanyName, _ address = c.Address, _ city = cust.City, _. Ountry = cust.ountry}) FirstOrDefault   

has been a while since I VB did, but it is necessary to do either work or only a tweak is required.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -