Can I extend a EntityCollection<Class> : LINQ to SQL
-
19-09-2019 - |
Question
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)
{
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow