本文整理汇总了C#中IEntityType.IsAbstract方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityType.IsAbstract方法的具体用法?C# IEntityType.IsAbstract怎么用?C# IEntityType.IsAbstract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityType
的用法示例。
在下文中一共展示了IEntityType.IsAbstract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMaterializeExpression
public virtual Expression CreateMaterializeExpression(
IEntityType entityType,
Expression valueBufferExpression,
int[] indexMap = null)
{
// ReSharper disable once SuspiciousTypeConversion.Global
var materializer = entityType as IEntityMaterializer;
if (materializer != null)
{
return Expression.Call(
Expression.Constant(materializer),
((Func<ValueBuffer, object>)materializer.CreateEntity).GetMethodInfo(),
valueBufferExpression);
}
if (!entityType.HasClrType())
{
throw new InvalidOperationException(CoreStrings.NoClrType(entityType.Name));
}
if (entityType.IsAbstract())
{
throw new InvalidOperationException(CoreStrings.CannotMaterializeAbstractType(entityType));
}
var instanceVariable = Expression.Variable(entityType.ClrType, "instance");
var blockExpressions
= new List<Expression>
{
Expression.Assign(
instanceVariable,
Expression.New(entityType.ClrType.GetDeclaredConstructor(null)))
};
blockExpressions.AddRange(
from mapping in _memberMapper.MapPropertiesToMembers(entityType)
let propertyInfo = mapping.Item2 as PropertyInfo
let targetMember
= propertyInfo != null
? Expression.Property(instanceVariable, propertyInfo)
: Expression.Field(instanceVariable, (FieldInfo)mapping.Item2)
select
Expression.Assign(
targetMember,
CreateReadValueExpression(
valueBufferExpression,
targetMember.Type,
indexMap?[mapping.Item1.GetIndex()] ?? mapping.Item1.GetIndex())));
blockExpressions.Add(instanceVariable);
return Expression.Block(new[] { instanceVariable }, blockExpressions);
}