我为一张桌子设计了一个抽象类
namespace Test.Data
{
[Table("Parameter")]
public abstract class Parameter
{
[StringLength(200)]
protected string title { get; set; }
protected decimal? num { get; set; }
public Int16 sts { get; set; }
}
}
并从它扩展了一些类(TPH)我发现当属性定义为受保护时,它们不会在数据库中生成,它们应该是公共的(以上是受保护的其他 sts)。但我想从另一个命名空间隐藏上述属性并为它们使用不同的名称,例如:
namespace Test.Data
{
public class Measure:Parameter
{
[NotMapped]
public string Title { get { return ttl; } set { ttl = value; } }
}
}
namsespace Test.Model
{
public class MeasureModel:Data.Measure
{
public void AddNew()
{
var m = new Data.Measure();
m.Title="meter"; //other measure's properties shouldn't accessable here
}
}
}