ObjectContainerDataSource with Linq To SQL

Apr 2, 2008 at 3:06 PM

Was trying to use the ObjectContainerDataSource together with Linq To SQL. I have some data which i need to display grouped, and currently returning anonymous types to the data source of the ObjectContainerDataSource when the form is loaded. Wanted to know if this is such a good idea for testability (or any other concerns), or whether i should create and use a "stronger" typed object rather than anonymous types?

Apr 2, 2008 at 5:05 PM
This approach sounds reasonable.
I can't think of any reasons it would cause problems or not work. I think the ObjectContainerDataSource should play well with any type, even anonymous types, but this is not a scenario we explictly tested.

On your concerns for testability, I think you would be ok if you break the code that does manipulation of the data via Linq into its own, testable methods. Maybe you have a method called GroupData, which does the Linq group by call. Methods like this should be unit testable. Of course, they may need to live in a helper class of some sort for separation of concerns...

I hope this helps. Let us know if you hit any snags.

Michael Puleio - patterns & practices