I'm building LINQ Models by hand, because I want to (understand what's reall happening).
There is a great light weight tutorial on turning standard classes into Linq Models I am reading Here.
For my sample application I have created some models that look like:
public class LoginModel
{
[Column(IsPrimaryKey=true,
DbType="UniqueIdentifier NOT NULL",
CanBeNull=false)]
public Guid LoginID { get; set; }
// .. and more question useless properties...
}
I'm definitely seeing a pattern for the primary key which led me to creating...
[AttributeUsage(AttributeTargets.Property
| AttributeTargets.Field,
AllowMultiple = false)]
public sealed class ColumnPrimaryKeyAttribute : DataAttribute
{
public ColumnPrimaryKeyAttribute()
{
CanBeNull = false;
IsPrimaryKey = true;
DbType = "UniqueIdentifier NOT NULL";
}
// etc, etc...
}
So when I use my new Attribute, LINQ is not picking up my attribute (even though it inherits from the same DataAttribute
as Column
. Is there a step I'm missing, or should I abandon this idea?