I found this question/answer about setting linq to sql classes as internal, but one thing I found is that classes generated for stored procedure return types are set as public, and even though I set the access modifier for the stored procedure and the data contest class as internal, the generated class for the stored proc is still public. How can I make it internal. I'm doing this in a seperate data access layer assembly, so I don't want these classes exposed to applicaitons.
+1
A:
Create a partial classes to call the stored procedures. I would generate the code as normal then paste them into a separate file and then delete the stored procedures from the design surface. You can then set the access modifiers as you wish. This is also a useful technique for dealing with stored procedures whereLINQ to SQL does not generate the classes as you would expect, such as those that use temporary tables.
internal partial class DataClasses2DataContextExtended : System.Data.Linq.DataContext {
[Function(Name="dbo.SPDEMO")]
internal ISingleResult<SPDEMOResult> SPDEMO()
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())));
return ((ISingleResult<SPDEMOResult>)(result.ReturnValue));
}
}
internal partial class SPDEMOResult
{
public SPDEMOResult()
{
}
public System.Nullable<int> FilmID
{ get; set; }
public string FilmName
{ get; set; }
}
PJB
2009-12-23 22:46:53