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


source to share





All Articles