LInq to SQL - Partial Class - C#
I have a system with 2 different projects, one is called LINQ_Extensions and the other is ORM_Linq.
On ORM_Linq i have the LINQ diagram with the SQL tables "converted" in clases. One of the Class is called "Tipos_Pago"
In the other project i have another class (partial class) "Tipos_Pago". I want to use the method OnValidate to validate the properties include in the class "Tipos_Pago", so i create this partial class.
In the 2 projects i put the same NameSpace "ORM_Linq"(I changed the NameSpace of the project "LINQ_Extensions" to have the same of the project "ORM_Linq")
After those chages, Visual Studio give me this error:
Error 1 No defining declaration found for implementing declaration of partial method 'ORM_Linq.Tipos_Pago.OnValidate(System.Data.Linq.ChangeAction)' C..\Tipos_Pago.cs 13 22 Extensiones_Linq
I don't have any Idea of what happend, can someone help me?
Thanks, sorry for my poor english
This is the code in the partial class:
namespace ORM_Linq
{
开发者_如何转开发public partial class Tipos_Pago
{
partial void OnValidate(System.Data.Linq.ChangeAction action)
{
//Valid code
}
}
}
You can't implement a partial across 2 projects, since they have to be compiled together, the partial
declarations must all be in the same project.
This same rule applies for methods and classes.
You need to create your partial implementation in the same project as the designer-generated classes.
From the Microsoft documentation:
All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). Partial definitions cannot span multiple modules.
精彩评论