Create return type based on table function

I often have a group of table functions that return datasets with the same structure (same column names, types, and order).

If I just drag and drop functions into the Linq2Sql constructor, the designer creates a new anonymous result type for each of the functions, and the functions are not compatible with the results.

To tell the developer the functions have the same result type, I need to drag and drop the functions onto the existing Linq2Sql class.

This is fine, but I have to manually create the class every time (insert new table on design surface, press repeatedly Insertto insert columns, type in column names, client side data types and server side data, side data types). This can be very time consuming if there are many columns and many functions.

Is there a way to tell the developer to automatically create an entity (table class) by looking at the table valued function so that I can then drag the rest of the functions onto that object

My current workaround:

  • Create a view on the server:

    create view dbo.stupid_linq as select * from dbo.FunctionIWant(bogus_params);
    
          

  • Drag this view into the constructor that creates the object.

  • Disconnect the object from the database by deleting it Source

    .

  • Rename the entity.

  • Delete the view on the server.

  • Drag table functions onto the object.

+3
orm return-type linq-to-sql user-defined-functions


source to share


No one has answered this question yet

Check out similar questions:

five
Valued Param UdtTypeName table
3
Guidelines for Using LINQ + Type Tables
3
How to map table related functions in EF6 code. First with different column names?
1
Return a table dynamically with different columns in a custom table function.
1
Insert using Linq-to-SQL where IDENTITY_INSERT is set to OFF
0
Map classes to database from ado.net
0
Returns a custom type joining two Linq to SQL tables
0
Multiple return types in MyBatis?
0
CLR Table Valued Function - check steps to create
0
Return type of the table



All Articles
Loading...
X
Show
Funny
Dev
Pics