There are two contexts of two data.

var o = (from a in dc.ozon select a); var v = (from a in dc.labirint select a); 

How do I merge their data and display a single table in a general table in the view.

enter image description here

  • The data context you have is one - dc . Do you need to list the different objects (you get the labirint o collection and the v ozon collection) in one table? - koks_rs
  • @ koks-rs Yes, that's right. - shatoidil

1 answer 1

You can use Join and create a collection of anonymous objects.

 var result = from ozon in dc.ozon join labirint in dc.labirint on ozon.isbn equals labirint.isbn select new { Name = labirint.Name, book_id = labirint.book_id... }; 

If the anonymous type does not fit, then create a model in which there are the necessary properties and fill in the same type

You can read more here in Russian

  • but you can just without equals, I need to display just general data without any conditions? - shatoidil
  • Not general data, but simply all the data from both tables - shatoidil
  • @shatoidil, in this case, you need Full Outer Join, instead of the usual. Or simply create a list of List <Model> objects and add two of your collections there, where the model will have properties from two tables - koks_rs
  • @ koks-rs If possible, correct your answer, this was the essence of my question. How to combine two collections is simple, without any conditions - shatoidil