Link to many?

Say I have products and receipts in many ways. Is there a way in which I can directly query product.receipts or receipt.products and get Iqueryable without reference to join_table at all?

+3
source share
2 answers

I assume you are using Linq-to-SQL.

The answer is "no, but ..."

You can work with many relationships in Linq-to-SQL, but you need to have a separate type representing the connection table.

If you just want, for example, a databind against a child property of a model object, you can do something really simple: -

public partial class Order
{
  public IEnumerable<Product> Products
  {
    get { return Order_Details.Select(x => x.Product); }
  }
}

select-n-plus-one, , .

: http://www.iaingalloway.com/2015/06/many-to-many-relationships-in-linq-to-sql.html .

, : -

LINQ --: ?

LINQ?

.

+2

Linq to Entities, Entity Framework - . , Linq Sql , ( ) Linq NHibernate . ( , NHibernate --)

0

Source: https://habr.com/ru/post/1730855/


All Articles