views:

63

answers:

2

Hi,

In my project I create the Linqto-SQL Classes using SqlMetal. The problem with this is that SqlMetal doesnt appear to create a parameterless constructor. I've always got round this because in my code I can always get the default connectionstring name and pass it to the constructor, however now I am being forced to use a linqdatasource in markup, not code, where I can't specify a constructor.

Is there any way of forcing SQLMetal to generate a parameterless constructor, or flipping it on its head, is there atctually a way of doing something like the following in the markup?

ContextTypeName="MyNameSpace.DAL(defaultconnStr)"

Thanks in advance higgsy

A: 

I think you can create a partial with a new parameterless contructor

Fujiy
A: 

SqlMetal should have generated your Entities class using a partial class. You should be able to simply add a parameterless constructor in another partial class definition:

public partial class WhateverYourEntitiesAreCalledEntities():
    this(defaultConnStr)
{
}
Justin Niessner