Try this:
int? id =
(from t in things where t.Name == Foo select t.Id)
.ToArray()
.Concat(new int?[] { null })
.First();
Cheers.
James.
From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On
Behalf Of Greg
Hi Greg.
FirstOrDefault() will return 0 for non null Ints, So I'm guessing that
t.Id is an (int).
So you're going to have to do something like this.
ListAB abs = new ListAB();
for (int i = 0; i 10; i++)
{
abs.Add(new AB { Id = i });
}
int? id = (from t in things where t.Name == Foo select new
int?(t.Id)).FirstOrDefault();
On 4 March 2013 18:19, Greg Keogh g...@mira.net wrote:
Folks, I want to select the int Id of an entity in a DbSet, or int? null if
it's not found. Like this wrong sample:
int? id = (from t in things