Return nested alias for linq expression

Posted by Schotime on Stack Overflow See other posts from Stack Overflow or by Schotime
Published on 2010-04-22T01:20:18Z Indexed on 2010/04/22 1:23 UTC
Read the original article Hit count: 338

I have the following Linq Expression

var tooDeep = shoppers
    .Where(x => x.Cart.CartSuppliers.First().Name == "Supplier1")
    .ToList();

I need to turn the name part into the following string.

x.Cart.CartSuppliers.Name

As part of this I turned the Expression into a string and then split on the . and removed the First() argument. However, when I get to CartSuppliers this returns a Suppliers[] array. Is there a way to get the single type from this. eg. I need to get a Supplier back.

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ