一个比较奇怪的构造器
[AttributeUsage(AttributeTargets.Class)]
public class PrimaryKeyAttribute : Attribute
{
public PrimaryKeyAttribute(string primaryKey)
{
Value = primaryKey;
autoIncrement = true;
}
public string Value { get; private set; }
public string sequenceName { get; set; }
public bool autoIncrement { get; set; }
}
//实例化
[TableName("tbCSW_HJCGLPlanning")]
[PrimaryKey("PID", autoIncrement = true)]
[ExplicitColumns]
public class tbCSW_HJCGLPlanning : Repo.Record<tbCSW_HJCGLPlanning>
{
我没看到有
[PrimaryKey("PID", autoIncrement = true)]
这个的构造函数,鼠标放上去的时候提示:命名参数。
有点怪,难道可以像js那样动态赋予属性吗? class
[解决办法]
这是Attribute的一种写法而已。
本质上来说,虽然写法不同,编译器却做了相同的处理。