Sub Query

S

shapper

Hello,

I have a sub query in a Linq query:

var data = (from a in database.A
select new B {
B1 = (from b in database.B
join b in database.B on a.AID equals
b.AID
select b).ToList(),
B2 = ?????????
}).ToList();

I want B2 to be a conversion of B1 to Array.

So B2 = B1.ToArray();

But is it possible to make this in the Linq query?

In SQL I would give a name to the table produced by the Sub Query and
then I would use that.

Thanks,
Miguel
 
C

Cowboy \(Gregory A. Beamer\)

Try writing multiple linq queries and using the results of the other queries
in your final result. Not sure on the array part, however. Will have to mull
that one over.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
S

shapper

Try writing multiple linq queries and using the results of the other queries
in your final result. Not sure on the array part, however. Will have to mull
that one over.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my bloghttp://feeds.feedburner.com/GregoryBeamer#

or just read it:http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box!                               |

Yes,

I have this working as follows:

var data = (from a in database.A
select new B {
B1 = (from b in database.B
join b in database.B on a.AID equals
b.AID
select b).ToList()
}).ToList();

B2 = B1.Select(t => t.Property).ToArray()

I was just wondering if I could integrate this code line in the
query ... just that.

Thanks,
Miguel
 

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

Similar Threads


Top