Is it possible to override an attibute set on a partial class?
So I have one autogenerated partial class like this:
[Table(Name="dbo.Users")]
public partial class MbsUser : INotifyPropertyChanging, INotifyPropertyChanged
{
This is generated in my DBML. The problem is, I don't want my class to use this table. I've created a view called "dbo.ActiveUsers" and would like this to be used instead (to keep out deactivated users).
I've tried 开发者_JAVA技巧creating another partial class with the same attribute as follows:
[Table(Name = "dbo.MbsUsersActive")]
public partial class MbsUser : IEquatable<MbsUser>
{
But I get the error:
Duplicate 'Table' attribute
You get that error because an attribute can control whether there are one or many intances of that attribute in the [AttributeUsage] declaration, and it declares only one. No, that isn't going to work unfortunately...
Why don't you change the mapping in the designer to point to the new entity? Don't know if that will work the same, but its worth a try.
精彩评论