Property in class is IEnumerable<TDto> get TDto.A == a

Posted by Miau on Stack Overflow See other posts from Stack Overflow or by Miau
Published on 2010-03-22T16:57:38Z Indexed on 2010/03/22 17:01 UTC
Read the original article Hit count: 269

Filed under:
|

So I have a class is something like this

public class Order
{
    //some other stuff ... 
    //setting the internal _orderItems collection ...
    IEnumerable<OrderItems> OrderItems { get { return _orderItems; }
}

public class OrderItem
{
    //other stuff
    public string ProductName {get; set;}
}

If I have a collection of orders of some sort and have access via linq to the order, something like

 myOrderRespository.Where(x=>x.OrderItems)

Then I only have access to getEnumerator there, waht I would like it to be able to do something like

 myOrderRespository.Where(x=>x.OrderItems.ProductName == "Blah")

Is this possible? this is a made up scenario and its pseudo code I m trying to simplify the problem so its easy to explain ( so please forgive me if there are a few errors) Cheers

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#