Starting to enjoy linq but have dilemma..
I have 3 tables tasks, tasktags, and tags
How can i create a linq query that returns all the tasks that have tag o f
tagid=9
Some tasks may have many tags, so only want to return unique tasks.
What methodology should i use to
If you have all the constraints set up correctly and you are using EF.
from t in tasks
.Include (TaskTags)
.Include(TaskTags.Tags)
where t.tagId = 9 select t;
you should get back a nice object with all the info that you want.
Davy.
Davy,
So you want to keep data which is local, only
Try
int? foundId = context.Things.Where(t = t.ID == lookupID).Select(t =
t.ID).SingleOrDefault();
Michael M. Minutillo
Indiscriminate Information Sponge
http://codermike.com
On Thu, Jul 26, 2012 at 7:26 PM, Greg Keogh g...@mira.net wrote:
I have to find an object in an EF4 entity
that doesnt work Mike?
did you mean:
int? foundId = context.Things.Where(t = t.ID == lookupID).Select(t =
*(int?)* t.ID).SingleOrDefault();
On 26/07/2012 8:05 PM, Michael Minutillo wrote:
Try
int? foundId = context.Things.Where(t = t.ID == lookupID).Select(t =
t.ID).SingleOrDefault();
var t = ( from t in things where t.id = lookupID select t.id
).FirstOrDefault();
Because I prefer the SQL syntax.
Davy
Sent via telegraph.
On 26 Jul 2012, at 14:47, Wallace Turner wallacetur...@gmail.com wrote:
that doesnt work Mike?
did you mean:
int? foundId = context.Things.Where(t = t.ID
Assuming ID is the primary key, I think using Find , and living with the
null check, might be more efficient because you are then leaning on the
first level cache.
On Thu, Jul 26, 2012 at 10:05 PM, Michael Minutillo
michael.minuti...@gmail.com wrote:
Try
int? foundId = context.Things.Where(t
I have a question similar to Greg's, but instead of one id, what is the
best way to deal with a list of Id's and return everything that matched?
Of course one can use a for loop for the id's, but is there a way to deal
with list of id's in one go? What would the generated Sql look like?
Regards
Wouldn't a simple Join do what you want ?
|-Original Message-
|From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-
|boun...@ozdotnet.com] On Behalf Of Arjang Assadi
|Sent: Friday, 27 July 2012 11:08 AM
|To: ozDotNet
|Subject: Re: LINQ question
|
|I have a question similar to Greg's
[mailto:ozdotnet-
|boun...@ozdotnet.com] On Behalf Of Arjang Assadi
|Sent: Friday, 27 July 2012 11:08 AM
|To: ozDotNet
|Subject: Re: LINQ question
|
|I have a question similar to Greg's, but instead of one id, what is the
best way to
|deal with a list of Id's and return everything that matched
On 27 July 2012 11:38, Bill McCarthy bill.mccarthy.li...@live.com.auwrote:
Wouldn't a simple Join do what you want ?
Yes, and that is what I have been using, but being able to say where id is
in list would save making a join where it is not really a join that we are
trying to make.
For some
10 matches
Mail list logo