asp.net mvc - Linq to SQL Entity Splitting -


I have recently started playing with the ASP .NET MVC NerdDinner sample, and as part of it you It can look good with Linq from SQL class, so I tried to remove (probably a boy before time!) And tried to create my own MVC application, but this time Linq to SQL Modeling your own simple database with.

This is going to be

  • Traveler
  • Traveler
  • Table Carpooler

  • There is a mapping table between Em> car and person (it has two columns: CarId, PersonId).

    In SQL, in SQL, I get a square for each table. But, what I really want is a class for the car , whose property is carpasizer , with each child person , the actual FK Rather (to select the result is OK, but to update the car with the new person objects, I have to first build them - I can only add an entity set of carpasors without installation of only the person's person objects) .

    I'm looking around and I have seen that the ADO The Net Entitie Framework will allow me to use unit splitting to get it, but I'm surprised Linq to SQL is an easy way to complete the same thing, and if not, with my MVC App NAT EF What is affected in the case of integrating

    Any advice, comments, tips will be greatly appreciated.

    Thank you!

  • If you define FK before adding them to the surface of the designer, What would you expect to be closer to the way carpasengers will exist but this would be an entity set of carpasenger objects, not the person. Those items, however, will be will EntityRef is an affiliate, this will allow you to find passengers in the car.

      var car = db.Car.Where (c => c.CarId == ID); Var passengers = db.Car.CarPassengers.Select (cp = & gt; cp.Person);  

    Adding new travelers also works, but there is another step in it too.

      var car = db.Car.Where (c => c.CarId == ID); Var person = new person {...}; car. Carpager. Add (new carzager {person = person});  

    If you do not have a timely defined FK relationship, you can always add affiliate to the designer manually. MSDN is on this topic.


    Comments

    Popular posts from this blog

    c# - ListView onScroll event -

    PHP - get image from byte array -

    Linux Terminal Problem with Non-Canonical Terminal I/O app -