Search code examples
c#.netlinq-to-sqlpartial-classes

Can I extend a EntityCollection<Class> : LINQ to SQL


Can I extend or use partial classes to add more functions to EntityCollection< Class>

eg.

this is the auto-generated classses from LINQ to SQL

customer.Orders

I want to be able to do

customer.Orders.FindByOrderID(orderID)

but Order is EntityCollection < Order >

Can I make this a partial class or extend it like I can do with just the Order class?


Solution

  • Yes I can

    public static class OrderExtension
    {
        public static Order FindByOrderID(this EntityCollection<Order> orders, String orderID)
        {