Writing to the DataContext
Posted
by
user738383
on Stack Overflow
See other posts from Stack Overflow
or by user738383
Published on 2011-12-05T15:20:39Z
Indexed on
2012/11/18
11:01 UTC
Read the original article
Hit count: 201
c#
|datacontext
I have a function. This function takes an IEnumerable<Customer>
(Customer
being an entity). What the function needs to do is tell the DataContext
(which has a collection of Customers
as a property) that its Customers
property needs to be overwritten with this passed in IEnumerable<Customer>
. I can't use assignment because DomainContext.Customers
cannot be assigned to, as it is read only.
I guess it's not clear what I'm asking, so I suppose I should say... how do I do that? So we have DataContext.Customers (of type System.Data.Linq.Table) which wants to be replaced with a System.Collections.Generic.IEnumerable. I can't just assign the latter to the former because DataContext's properties are read only. But there must be a way.
Edit: here's an image:
Further edit: Yes, this image does not feature a collection of the type 'Customer' but rather 'Connection'. It doesn't matter though, they are both created from tables within the linked SQL database. So there is a dc.Connections, a dc.Customers, a dc.Media and so on.
Thanks in advance.
© Stack Overflow or respective owner