[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Linq to Sql Filtering child table

Benny

10/14/2008 5:57:00 PM

I am trying to select certain data from a parent table, but would like
to constrain the results based on the child tables attributes. The
relationship is a one to many so if i try to specify a filter for the
child table, i unable to access the child attributes. Does anyone
have any ideas on how i might be able to do this?

An example of the relationship is below:

Country
-----------
CountryId
Name

State
-------
StateId
CountryId
Name
Population

I want to select only States with city populations greater than
50,000.

Thanks in advance!
Ben
2 Answers

Cowboy

10/14/2008 8:25:00 PM

0

One SQL Query might look like this:

SELECT * FROM State
WHERE StateID IN (SELECT DISTINCT StateID FROM City WHERE Population >
50000)

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

Subscribe to my blog
http://feeds.feedburner.com/Greg...

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

********************************************
| Think outside the box! |
********************************************
"Benny" <bennyandlinds@gmail.com> wrote in message
news:e155c322-242f-4fb4-9922-f144e6165cd2@r38g2000prr.googlegroups.com...
>I am trying to select certain data from a parent table, but would like
> to constrain the results based on the child tables attributes. The
> relationship is a one to many so if i try to specify a filter for the
> child table, i unable to access the child attributes. Does anyone
> have any ideas on how i might be able to do this?
>
> An example of the relationship is below:
>
> Country
> -----------
> CountryId
> Name
>
> State
> -------
> StateId
> CountryId
> Name
> Population
>
> I want to select only States with city populations greater than
> 50,000.
>
> Thanks in advance!
> Ben

Naked Gonad

11/24/2008 2:24:00 PM

0

Eli Grubman wrote:
> On Mon, 24 Nov 2008 12:52:37 +0000, Naked Gonad
> <bodron57@tiscali.co.uk> wrote:
>
>> Eli Grubman wrote:
>>> On Mon, 24 Nov 2008 12:00:43 +0000, Naked Gonad
>>> <bodron57@tiscali.co.uk> wrote:
>>>
>>>> Eli Grubman wrote:
>>>>> On Mon, 24 Nov 2008 11:28:14 +0000, Naked Gonad
>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>
>>>>>> Eli Grubman wrote:
>>>>>>> On Mon, 24 Nov 2008 09:20:48 +0000, Naked Gonad
>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>
>>>>>>>> Eli Grubman wrote:
>>>>>>>>> On Tue, 18 Nov 2008 09:35:29 +0000, Naked Gonad
>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>
>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>> On Mon, 17 Nov 2008 18:44:59 +0000, Naked Gonad
>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>> On Mon, 17 Nov 2008 17:15:19 +0000, Naked Gonad
>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 16:20:14 +0000, Naked Gonad
>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 15:25:44 +0000, Naked Gonad
>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 14:31:28 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 13:48:49 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 12:00:05 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 11:37:19 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>> On Mon, 17 Nov 2008 09:44:28 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, 16 Nov 2008 19:17:32 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, 16 Nov 2008 17:52:02 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, 16 Nov 2008 17:05:58 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, 16 Nov 2008 16:08:21 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> John "C" wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "Naked Gonad" <bodron57@tiscali.co.uk> wrote in message
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> news:49203aed_3@mk-nntp-2.news.uk.tiscali.com...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> John "C" wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "Naked Gonad" <bodron57@tiscali.co.uk> wrote in message
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> news:49202d0f$1_4@mk-nntp-2.news.uk.tiscali.com...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, 16 Nov 2008 12:57:22 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, 16 Nov 2008 08:52:03 +0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Eli Grubman wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Sat, 15 Nov 2008 19:36:04 -0000, "Peter Hucker"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <none@spam.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Fri, 14 Nov 2008 23:28:25 -0000, Eli Grubman
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <eli.grubman@googlemail.com> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Fri, 14 Nov 2008 18:33:50 -0000, "Peter Hucker"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <none@spam.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Thu, 13 Nov 2008 04:15:28 -0000, Eli Grubman
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <eli.grubman@googlemail.com> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Wed, 12 Nov 2008 18:53:55 -0000, "Peter Hucker"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <none@spam.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Tue, 11 Nov 2008 19:33:48 -0000, Naked Gonad
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <bodron57@tiscali.co.uk> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Peter Hucker wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Tue, 11 Nov 2008 03:40:32 -0000, Eli Grubman
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <eli.grubman@googlemail.com> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> On Mon, 10 Nov 2008 19:18:38 -0000, "Peter Hucker"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <none@spam.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Would it have made a difference if it wasn't there?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Yes, see my reply to Gonad.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Nought is accepted as meaning nothing generally.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> In a bank account 0 or 0 recurring=nothing, try
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> convincing
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> the bank that the 0 counts as anything more than
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> nothing.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> It is not the same as nothing. An empty bank account is
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> not the same as no bank account.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> One is as useless as the other.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Not if you have an overdraft agreement.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> That's even worse.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Rubbish. Take the banks for all they've got!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> And when you can't pay they'll take you for all you've got (if
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> anything).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> They will have already done that by charging high interest on
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> overdraft.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> And if you can't afford to pay back the interest they will go
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> after
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> your car/house/wife/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> The last resort will be to shoot you.(give it time).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Don't you people have debtors' prisons any more???
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Bring back the workhouses!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Bring back the whore houses!!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Filthy but nice.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Thanks, pal.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> They should build blow job bars.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> We have those.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Does it give one the blow job blues?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> They're mostly for the blecks. You'd have to ask one of them.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Zippadee doo da!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Yeah, he's one of them. BOING!!!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Time for bed?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Those demn blecks, that's all they think of.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>> Possible sleeping sickness?
>>>>>>>>>>>>>>>>>>>>>>>>>>> Probably just lazy kaffirs.
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>> Possibly comatose?
>>>>>>>>>>>>>>>>>>>>>>>>> It often seems that way until one sets the dogs on them.
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> But they could be barking up the wrong tree.
>>>>>>>>>>>>>>>>>>>>>>> Not to worry. They'll hound them down.
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> Only if they twig it!
>>>>>>>>>>>>>>>>>>>>> Even if they branch out, they'll get caught.
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> But who be-leaves that?
>>>>>>>>>>>>>>>>>>> It's treeson not to!
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Wouldn't that sap ones strenght?
>>>>>>>>>>>>>>>>> Not if one is firmy rooted in position.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> But that doesn't stop trunk rot though.
>>>>>>>>>>>>>>> It wood, woodn't it?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You'd have to check the rings for that.
>>>>>>>>>>>>> Why not just axe it how old it is?
>>>>>>>>>>>>>
>>>>>>>>>>>> Always keep both hands on yer chopper!
>>>>>>>>>>> Shiver me timbers!
>>>>>>>>>>>
>>>>>>>>>> Is that like tree hugging?
>>>>>>>>> Commie pinko faggot treehugging bedwetters.
>>>>>>>>>
>>>>>>>> There's one in every jungle (apparently).
>>>>>>> So many trees so little time...
>>>>>>>
>>>>>> Good, only for tree spotters.
>>>>> Spotty trees?
>>>>>
>>>> Diseased, possibly suffering from ringworm?
>>> Deforestation is the only cure.
>>>
>> A good excuse to get yer chopper out?
>
> Go forth and fertilise.
>
Or, go fourth and cum first.