Scenario:
Trying to call the .AttachAll
method on a table in my LinqToSql DataContext object.
Here's the relevant simplified snippet:
public void Update(Customer cust){
MyDataContext db = new MyDataContext();
db.CustomerInvoices.AttachAll(cust.Invoices); //exception raised here!
db.Customer.Attach(cust);
}
Exception raised by the Compiler:
The type arguments for method 'System.Data.Linq.Table(Invoices).AttachAll(TSubEntity)(System.Collections.Generic.IEnumerable(TSubEntity))' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Question: What is the proper way to cast the collection properly? Any other solutions besides a cast?