本文整理汇总了C#中IEntityType.GetConcreteTypesInHierarchy方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityType.GetConcreteTypesInHierarchy方法的具体用法?C# IEntityType.GetConcreteTypesInHierarchy怎么用?C# IEntityType.GetConcreteTypesInHierarchy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityType
的用法示例。
在下文中一共展示了IEntityType.GetConcreteTypesInHierarchy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTables
public virtual IReadOnlyList<InMemoryTableSnapshot> GetTables(IEntityType entityType)
{
var data = new List<InMemoryTableSnapshot>();
lock (_lock)
{
if (_tables.IsValueCreated)
{
foreach (var et in entityType.GetConcreteTypesInHierarchy())
{
IInMemoryTable table;
if (_tables.Value.TryGetValue(et, out table))
{
data.Add(new InMemoryTableSnapshot(et, table.SnapshotRows()));
}
}
}
}
return data;
}
示例2: CreateMaterializer
/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public virtual Expression<Func<IEntityType, ValueBuffer, object>> CreateMaterializer(IEntityType entityType)
{
Check.NotNull(entityType, nameof(entityType));
var entityTypeParameter
= Expression.Parameter(typeof(IEntityType), "entityType");
var valueBufferParameter
= Expression.Parameter(typeof(ValueBuffer), "valueBuffer");
var concreteEntityTypes
= entityType.GetConcreteTypesInHierarchy().ToArray();
if (concreteEntityTypes.Length == 1)
{
return Expression.Lambda<Func<IEntityType, ValueBuffer, object>>(
_entityMaterializerSource
.CreateMaterializeExpression(
concreteEntityTypes[0], valueBufferParameter),
entityTypeParameter,
valueBufferParameter);
}
var returnLabelTarget = Expression.Label(typeof(object));
var blockExpressions
= new Expression[]
{
Expression.IfThen(
Expression.Equal(
entityTypeParameter,
Expression.Constant(concreteEntityTypes[0])),
Expression.Return(
returnLabelTarget,
_entityMaterializerSource
.CreateMaterializeExpression(
concreteEntityTypes[0], valueBufferParameter))),
Expression.Label(
returnLabelTarget,
Expression.Default(returnLabelTarget.Type))
};
foreach (var concreteEntityType in concreteEntityTypes.Skip(1))
{
blockExpressions[0]
= Expression.IfThenElse(
Expression.Equal(
entityTypeParameter,
Expression.Constant(concreteEntityType)),
Expression.Return(
returnLabelTarget,
_entityMaterializerSource
.CreateMaterializeExpression(concreteEntityType, valueBufferParameter)),
blockExpressions[0]);
}
return Expression.Lambda<Func<IEntityType, ValueBuffer, object>>(
Expression.Block(blockExpressions),
entityTypeParameter,
valueBufferParameter);
}
示例3: CreateMaterializer
public virtual Expression<Func<ValueBuffer, object>> CreateMaterializer(
IEntityType entityType,
SelectExpression selectExpression,
Func<IProperty, SelectExpression, int> projectionAdder,
IQuerySource querySource)
{
Check.NotNull(entityType, nameof(entityType));
Check.NotNull(selectExpression, nameof(selectExpression));
Check.NotNull(projectionAdder, nameof(projectionAdder));
var valueBufferParameter
= Expression.Parameter(typeof(ValueBuffer), "valueBuffer");
var concreteEntityTypes
= entityType.GetConcreteTypesInHierarchy().ToArray();
var indexMap = new int[concreteEntityTypes[0].PropertyCount()];
var propertyIndex = 0;
foreach (var property in concreteEntityTypes[0].GetProperties())
{
indexMap[propertyIndex++]
= projectionAdder(property, selectExpression);
}
var materializer
= _entityMaterializerSource
.CreateMaterializeExpression(
concreteEntityTypes[0], valueBufferParameter, indexMap);
if (concreteEntityTypes.Length == 1
&& concreteEntityTypes[0].RootType() == concreteEntityTypes[0])
{
return Expression.Lambda<Func<ValueBuffer, object>>(materializer, valueBufferParameter);
}
var discriminatorProperty = _relationalAnnotationProvider.For(concreteEntityTypes[0]).DiscriminatorProperty;
var discriminatorColumn
= selectExpression.Projection
.OfType<AliasExpression>()
.Last(c => c.TryGetColumnExpression()?.Property == discriminatorProperty);
var firstDiscriminatorValue
= Expression.Constant(
_relationalAnnotationProvider.For(concreteEntityTypes[0]).DiscriminatorValue);
var discriminatorPredicate
= Expression.Equal(discriminatorColumn, firstDiscriminatorValue);
if (concreteEntityTypes.Length == 1)
{
selectExpression.Predicate
= new DiscriminatorPredicateExpression(discriminatorPredicate, querySource);
return Expression.Lambda<Func<ValueBuffer, object>>(materializer, valueBufferParameter);
}
var discriminatorValueVariable
= Expression.Variable(discriminatorProperty.ClrType);
var returnLabelTarget = Expression.Label(typeof(object));
var blockExpressions
= new Expression[]
{
Expression.Assign(
discriminatorValueVariable,
_entityMaterializerSource
.CreateReadValueExpression(
valueBufferParameter,
discriminatorProperty.ClrType,
discriminatorProperty.GetIndex())),
Expression.IfThenElse(
Expression.Equal(discriminatorValueVariable, firstDiscriminatorValue),
Expression.Return(returnLabelTarget, materializer),
Expression.Throw(
Expression.Call(
_createUnableToDiscriminateException,
Expression.Constant(concreteEntityTypes[0])))),
Expression.Label(
returnLabelTarget,
Expression.Default(returnLabelTarget.Type))
};
foreach (var concreteEntityType in concreteEntityTypes.Skip(1))
{
indexMap = new int[concreteEntityType.PropertyCount()];
propertyIndex = 0;
foreach (var property in concreteEntityType.GetProperties())
{
indexMap[propertyIndex++]
= projectionAdder(property, selectExpression);
}
var discriminatorValue
= Expression.Constant(
_relationalAnnotationProvider.For(concreteEntityType).DiscriminatorValue);
//.........这里部分代码省略.........