views:

217

answers:

2

Is it possible to force the LINQ to SQL designer behavior editor to recognize properties on table entities that have not been generated by the designer itself? That is - I want to pass a custom property (defined in my own partial class) as a parameter to a stored procedure.

I've tried manually specifying the parameter name in the XML (which does wonders for certain other things, like forcing SP return types when the L2S designer can't grok the fact that a return type matches an existing table). Unfortunately this does not work.

I'm currently porting a set of web services written in .NET 1.1 to utilizing everything that's come along since then. I'm trying to consolidate all of the behavior that was taken care of by two layers of business objects (primarily field name changes from the DB to the objects and type conversions) in the LINQ objects.

The simplest solution in this case would be to just alter the type of the parameter for the SP in the DB, and it's what I'll do in this case. There are already three separate sets of SP's running around in the DB however. Old web services. .NET 2.0 web services and the website. I am trying to avoid a proliferation of WCF web service SPs as I figure that this will be a very common occurrence considering how most of the data access is done.

+3  A: 

There are a number of issues in the designer with support for partial class declared properties. Some of these are being addressed for 2010, but I'm not sure if this specific issue is covered. You may want to enter a bug item on connect.microsoft.com to get the team to look at it.

In the mean time, I suspect you are going to have to manually manage these functions in a partial class rather than through the designer/dbml. Much of LINQ to SQL's stored proc support is convention based, so as long as the method is named correctly, It should be used even if you don't explicitly configure it in the dbml.

Jim Wooley
A: 

It would appear "No", you will need to either:

  • Not use an SP for insert behaviour
  • Try Jim's suggestion
  • Persist the property, so it is available
  • Manually edit the generated code (yuck) *This is not a suggestion, merely an option!
MattH