Obtaining list of invoices for product in DLinq

A

Andrus

Invoice headers:

class Doc {
public int Dokumnr {get; set;}
}

Invoice rows:

class Row {
public int Dokumnr {get; set;}
public int Product {get; set;}
}

I need to get list of invoices which contain product 123.
In Sql I can write

SELECT *
FROM Doc
WHERE Dokumnr in (SELECT Dokumnr FROM Row WHERE Produce=123);

How to convert this to DLinq (Linq To Sql) ?

Andrus.
 
A

Arne Vajh¸j

Andrus said:
Invoice headers:

class Doc { public int Dokumnr {get; set;} }

Invoice rows:

class Row { public int Dokumnr {get; set;} public int Product {get;
set;} }

I need to get list of invoices which contain product 123.
In Sql I can write

SELECT * FROM Doc
WHERE Dokumnr in (SELECT Dokumnr FROM Row WHERE Produce=123);

How to convert this to DLinq (Linq To Sql) ?

Something like:

var q = from d in alldocs
where (from r in allrows where r.Product==123 select
r.Dokumnr).Contains(d.Dokumnr)
select d;

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top