It is not uncommon to have a stored procedure that peforms joins on multiple tables and returns a combined result set - much like LINQ will do dynamically.

Right now, I have to map my stored procedure to a single class mapped to a single table on the LINQ to SQL designer or I can allow LINQ to create an "(Auto-generated Type)".

If all the tables that are used in the Stored Procedure are currently mapped on the LINQ to SQL designer, is LINQ smart enough right now to populate the individual mapped classes with the data returned from the stored procedure

This would then allow me to use update methods associated with the specific classes if I choose to.

If this is possible now, please let me know how to do it. Thanks.

Re: LINQ Project General Stored Procedure - Intelligent multi-class mapping

Dinesh Kulkarni - MSFT

LINQ to SQL run-time can map to a sequence of results (IMultipleResults). However, each result can map only to one class. So mapping multiple entity classes to a single result which effectively joins tables mapped to two entity classes is not supported.

Due to complexity of getting metadata about multiple results, the multiple result set sproc feature is not currently (i.e. in V1) supported by the designer. Here is what the code looks like if you use SqlMetal or write it yourself:

Sproc wrapper code in class derived from DataContext looks like this for a sproc named MultipleResultTypesSequentially




public IMultipleResults MultipleResultTypesSequentially()


IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())));

return ((IMultipleResults)(result.ReturnValue));


The method can be used as follows:

using(IMultipleResults sprocResults = db.MultipleResultTypesSequentially()) {

List<Product> prods = sprocResults.GetResult<Product>().ToList();

List<Customer> custs = sprocResults.GetResult<Customer>().ToList();