tags:

views:

67

answers:

2

I m just starting with microsoft (MVC,C#, LINQ), so far so good, but i have a question about LINQ uses, How do i get the value form a LINQ like this one?

            var x = from a in db.tablex
                    where a.eventID == eventID
                    select new
                    {
                       owner = a.owner,
                        shipper = a.shipper,
                        consignee = a.consignee
                    };

I try something like "r.owner" inside a foreach to get the value retrieved from DB

foreach (var r in x)

but its not working.. i dont get intellisense either.. how do i get the value??. I saw several examples and it seems to work like this, but for some reason its not working.. Thanks

A: 
foreach (var r in x)
{
 var owner = r.owner;// not x.owner
}
ArsenMkrt
introducing `a` again is probably only going to add confusion... "var owner = r.owner;" would probably be clearer...
Marc Gravell
yea, you are right, I edited the post :)
ArsenMkrt
+1  A: 

Ok guys here was the thing, (it wasnt the typo it was just in the post), i was missing a using :

using System.Reflection;

with this C# automatically creates a class from them, and now it works

What a noob of me =).

Omar