.... argh... late edition. The last bit of code should be:
int kk = myData
.Select((p, i) =new { p.id, p.who, position = i })
.Where(q =q.who == "bye")
.Where(q =q.id == 22)
.Select((z) =z.position)
.ToList()[0];
"Michel Walsh" <vanderghastAro baseMsnDotCom@n ospam.comwrote in message
news:0AAC6558-65B7-4A9A-B3FC-FF5FB6D91DAA@mi crosoft.com...
int kk = myData
.Select((p, i) =new { p.id, p.who, position = i })
.Where(q =q.who == "bye")
.Where(q =q.id == 22)
.Select((z) =z.position)
.ToList()[0];
"Michel Walsh" <vanderghastAro baseMsnDotCom@n ospam.comwrote in message
news:0AAC6558-65B7-4A9A-B3FC-FF5FB6D91DAA@mi crosoft.com...
Just an important note. If you try:
>
int kk = myData
.Where(q =q.who == "bye")
.Where(q =q.id == 22)
.Select((z, i) =i)
.ToList()[0];
>
you end up with who="bye", id=22, as in position 0. Which is not what we
want. That is why we need the first Select, to un-deferred, to
'instantiate ( I borrow the expression, it is not an official one) the
'position':
>
>
>
int kk = myData
.Select((p, i) =new { p.id, p.who, position = i })
.Where(q =q.who == "bye")
.Where(q =q.id == 22)
.Select((z, i) =i)
.ToList()[0];
>
>
>
Still somehow un-usual to have a Where clause between two Select clauses.
>
>
>
Vanderghast, Access MVP
>
>
int kk = myData
.Where(q =q.who == "bye")
.Where(q =q.id == 22)
.Select((z, i) =i)
.ToList()[0];
>
you end up with who="bye", id=22, as in position 0. Which is not what we
want. That is why we need the first Select, to un-deferred, to
'instantiate ( I borrow the expression, it is not an official one) the
'position':
>
>
>
int kk = myData
.Select((p, i) =new { p.id, p.who, position = i })
.Where(q =q.who == "bye")
.Where(q =q.id == 22)
.Select((z, i) =i)
.ToList()[0];
>
>
>
Still somehow un-usual to have a Where clause between two Select clauses.
>
>
>
Vanderghast, Access MVP
>