How can I change the class name of stored procedure result generated by LINQ to SQL designer (besides messing with designer.cs)?
Also, how can you perform a linq query on the result set of the stored procedure?
clinqlinq-to-sqlsqltsql
How can I change the class name of stored procedure result generated by LINQ to SQL designer (besides messing with designer.cs)?
Also, how can you perform a linq query on the result set of the stored procedure?
Best Answer
Can you edit this in the dbml? Personally, I tend to treat the auto-generated types (from functions and stored procedures) as DTOs that are local to the DAL, so I immediately re-map them to my own POCO representation - i.e.
etc. Re the second question "Also, how can you perform a linq query on the result set of the stored procedure?" - I would recommend using a UDF instead of a stored procedure if you want to compose it: this allows you to do the composition at the database, for example paging and filtering:
which should (in LINQ-to-SQL at least) do everything in TSQL at the server. Otherwise, you can call
AsEnumerable()
and use LINQ-to-Objects at the calling .NET layer:To edit the dbml (which is just xml), change the
ElementType/@Name
here: