0
我需要爲十進制字段設置精度和刻度值。使用EF電動工具 - 檢索十進制精度和刻度
使用EF電動工具模板,我想內Mapping.tt自定義此部分:
foreach (var prop in efHost.EntityType.Properties)
{
var type = (PrimitiveType)prop.TypeUsage.EdmType;
var isKey = efHost.EntityType.KeyMembers.Contains(prop);
var storeProp = efHost.PropertyToColumnMappings[prop];
var sgpFacet = storeProp.TypeUsage.Facets.SingleOrDefault(f => f.Name == "StoreGeneratedPattern");
var storeGeneratedPattern = sgpFacet == null
? StoreGeneratedPattern.None
: (StoreGeneratedPattern)sgpFacet.Value;
// Other code from Mapping.tt
if (type.ClrEquivalentType == typeof(decimal))
{
int precision = **[Retrieve Precision Value]**;
int scale = **[Retrieve Scale Value]**;
configLines.Add(String.Format(".HasPrecision({0}, {1})", precision, scale));
}
}
如何獲取精度和規模值爲每個?
謝謝。
史蒂夫
可以因爲有在格式化明顯的錯字編輯你的答案。 – cmbarbu 2015-03-24 10:38:27