本文整理汇总了C#中IEntityType类的典型用法代码示例。如果您正苦于以下问题:C# IEntityType类的具体用法?C# IEntityType怎么用?C# IEntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEntityType类属于命名空间,在下文中一共展示了IEntityType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public override EntityKey Create(
IEntityType entityType, IReadOnlyList<IProperty> properties, IValueReader valueReader)
{
var components = new object[properties.Count];
for (var i = 0; i < properties.Count; i++)
{
var index = properties[i].Index;
if (valueReader.IsNull(index))
{
return EntityKey.InvalidEntityKey;
}
var value = _boxedValueReaders[i].ReadValue(valueReader, index);
if (Equals(value, _sentinels[i]))
{
return EntityKey.InvalidEntityKey;
}
components[i] = value;
}
return new CompositeEntityKey(entityType, components);
}
开发者ID:thegido,项目名称:EntityFramework,代码行数:26,代码来源:CompositeEntityKeyFactory.cs
示例2: IsSingleQueryMode
/// <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 bool IsSingleQueryMode(IEntityType entityType)
{
if (_singleQueryMode == false)
{
// Once we are out of SQM we are always out.
return false;
}
// If we already checked for self-refs then don't check again.
if (_singleQueryModeEntityType == entityType)
{
return true;
}
// Drop out if SQM for change of entity type or self-refs since query may not fix them up.
if (_singleQueryModeEntityType != null
|| entityType.GetNavigations().Any(n => entityType.IsSameHierarchy(n.GetTargetType())))
{
_singleQueryMode = false;
return false;
}
_singleQueryModeEntityType = entityType;
return true;
}
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:30,代码来源:StateManager.cs
示例3: StartTracking
public virtual InternalEntityEntry StartTracking(
IEntityType entityType, EntityKey entityKey, object entity, ValueBuffer valueBuffer)
{
if (entityKey == EntityKey.InvalidEntityKey)
{
throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName()));
}
var existingEntry = TryGetEntry(entityKey);
if (existingEntry != null)
{
if (existingEntry.Entity != entity)
{
throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName()));
}
return existingEntry;
}
var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueBuffer));
_identityMap.Add(entityKey, newEntry);
_entityReferenceMap[entity] = newEntry;
newEntry.SetEntityState(EntityState.Unchanged);
return newEntry;
}
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:29,代码来源:StateManager.cs
示例4: BindMixins
/// <summary>
/// Binds the mixins to the entity through change tracking.
/// </summary>
/// <param name="entry">The entity entry.</param>
/// <param name="entityType">The entity type.</param>
/// <param name="entity">The entity instance.</param>
private void BindMixins(InternalEntityEntry entry, IEntityType entityType, object entity)
{
var mixinHost = entity as ISupportMixins;
if (mixinHost != null)
{
var mixinTypes = entityType
.Annotations
.Where(a => a.Name == "MixinType")
.Select(a => (Type)a.Value)
.Distinct()
.ToArray();
foreach (var mixinType in mixinTypes)
{
// Create the mixin.
var mixin = (Mixin)Activator.CreateInstance(mixinType);
// Set the resolver.
mixin.SetPropertyEntryResolver(p => new PropertyEntry(entry, p));
// Assign to the host entity.
mixinHost.AddMixin(mixin);
}
}
}
开发者ID:Antaris,项目名称:EntityFrameworkMixins,代码行数:31,代码来源:InternalEntityEntryFactory.cs
示例5: StartTracking
public virtual InternalEntityEntry StartTracking(IEntityType entityType, object entity, IValueReader valueReader)
{
// TODO: Perf: Pre-compute this for speed
var keyProperties = entityType.GetPrimaryKey().Properties;
var keyValue = _keyFactorySource.GetKeyFactory(keyProperties).Create(entityType, keyProperties, valueReader);
if (keyValue == EntityKey.InvalidEntityKey)
{
throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName()));
}
var existingEntry = TryGetEntry(keyValue);
if (existingEntry != null)
{
if (existingEntry.Entity != entity)
{
throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName()));
}
return existingEntry;
}
var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueReader));
_identityMap.Add(keyValue, newEntry);
_entityReferenceMap[entity] = newEntry;
newEntry.SetEntityState(EntityState.Unchanged);
return newEntry;
}
开发者ID:thegido,项目名称:EntityFramework,代码行数:32,代码来源:StateManager.cs
示例6: Select
/// <summary>
/// Selects the appropriate value generator for a given property.
/// </summary>
/// <param name="property"> The property to get the value generator for. </param>
/// <param name="entityType">
/// The entity type that the value generator will be used for. When called on inherited properties on derived entity types,
/// this entity type may be different from the declared entity type on <paramref name="property" />
/// </param>
/// <returns> The value generator to be used. </returns>
public virtual ValueGenerator Select(IProperty property, IEntityType entityType)
{
Check.NotNull(property, nameof(property));
Check.NotNull(entityType, nameof(entityType));
return Cache.GetOrAdd(property, entityType, Create);
}
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:16,代码来源:ValueGeneratorSelector.cs
示例7: Create
public override EntityKey Create(IEntityType entityType, IReadOnlyList<IProperty> properties, IPropertyBagEntry propertyBagEntry)
{
Check.NotNull(entityType, "entityType");
Check.NotNull(properties, "properties");
Check.NotNull(propertyBagEntry, "propertyBagEntry");
return Create(entityType, properties.Select(p => propertyBagEntry[p]).ToArray());
}
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:8,代码来源:CompositeEntityKeyFactory.cs
示例8: Create
/// <inheritdoc />
public override InternalEntityEntry Create(IStateManager stateManager, IEntityType entityType, object entity, ValueBuffer valueBuffer)
{
var entry = base.Create(stateManager, entityType, entity, valueBuffer);
BindMixins(entry, entityType, entity);
return entry;
}
开发者ID:Antaris,项目名称:EntityFrameworkMixins,代码行数:9,代码来源:InternalEntityEntryFactory.cs
示例9: GetOrAdd
/// <summary>
/// Gets the existing value generator from the cache, or creates a new one if one is not present in
/// the cache.
/// </summary>
/// <param name="property"> The property to get the value generator for. </param>
/// <param name="entityType">
/// The entity type that the value generator will be used for. When called on inherited properties on derived entity types,
/// this entity type may be different from the declared entity type on <paramref name="property" />
/// </param>
/// <param name="factory"> Factory to create a new value generator if one is not present in the cache. </param>
/// <returns> The existing or newly created value generator. </returns>
public virtual ValueGenerator GetOrAdd(
IProperty property, IEntityType entityType, Func<IProperty, IEntityType, ValueGenerator> factory)
{
Check.NotNull(property, nameof(property));
Check.NotNull(factory, nameof(factory));
return _cache.GetOrAdd(new CacheKey(property, entityType, factory), ck => ck.Factory(ck.Property, ck.EntityType));
}
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:19,代码来源:ValueGeneratorCache.cs
示例10: CreateNewEntry
public virtual InternalEntityEntry CreateNewEntry(IEntityType entityType)
{
// TODO: Consider entities without parameterless constructor--use o/c mapping info?
// Issue #240
var entity = entityType.HasClrType() ? Activator.CreateInstance(entityType.ClrType) : null;
return _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity), null);
}
开发者ID:491134648,项目名称:EntityFramework,代码行数:8,代码来源:StateManager.cs
示例11: CompositeEntityKey
public CompositeEntityKey([NotNull] IEntityType entityType, [NotNull] object[] keyValueParts)
{
Check.NotNull(entityType, "entityType");
Check.NotNull(keyValueParts, "keyValueParts");
_entityType = entityType;
_keyValueParts = keyValueParts;
}
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:8,代码来源:CompositeEntityKey.cs
示例12: Select
public override ValueGenerator Select(IProperty property, IEntityType entityType)
{
Check.NotNull(property, nameof(property));
Check.NotNull(entityType, nameof(entityType));
return property.SqlServer().IdentityStrategy == SqlServerIdentityStrategy.SequenceHiLo
? _sequenceFactory.Create(property, Cache.GetOrAddSequenceState(property), _connection)
: Cache.GetOrAdd(property, entityType, Create);
}
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:9,代码来源:SqlServerValueGeneratorSelector.cs
示例13: Create
public override ValueGenerator Create(IProperty property, IEntityType entityType)
{
Check.NotNull(property, nameof(property));
Check.NotNull(entityType, nameof(entityType));
return property.ClrType.IsInteger()
? _inMemoryFactory.Create(property)
: base.Create(property, entityType);
}
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:9,代码来源:InMemoryValueGeneratorSelector.cs
示例14: Create
public override ValueGenerator Create(IProperty property, IEntityType entityType)
{
Check.NotNull(property, nameof(property));
Check.NotNull(entityType, nameof(entityType));
return property.ClrType == typeof(Guid)
? _sequentialGuidFactory.Create(property)
: base.Create(property, entityType);
}
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:9,代码来源:SqlServerValueGeneratorSelector.cs
示例15: CreateMaterializeExpression
public virtual Expression CreateMaterializeExpression(
IEntityType entityType,
Expression valueReaderExpression,
int[] indexMap = null)
{
Check.NotNull(entityType, nameof(entityType));
Check.NotNull(valueReaderExpression, nameof(valueReaderExpression));
var materializer = entityType as IEntityMaterializer;
if (materializer != null)
{
return Expression.Call(
Expression.Constant(materializer),
((Func<IValueReader, object>)materializer.CreateEntity).GetMethodInfo(),
valueReaderExpression);
}
if (!entityType.HasClrType())
{
throw new InvalidOperationException(Strings.NoClrType(entityType.Name));
}
if (entityType.IsAbstract)
{
throw new InvalidOperationException(Strings.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(
valueReaderExpression,
targetMember.Type,
indexMap?[mapping.Item1.Index] ?? mapping.Item1.Index)));
blockExpressions.Add(instanceVariable);
return Expression.Block(new[] { instanceVariable }, blockExpressions);
}
开发者ID:thegido,项目名称:EntityFramework,代码行数:57,代码来源:EntityMaterializerSource.cs
示例16: AggregateDescriptor
public AggregateDescriptor(IEntityType aggregateRoot, IEntityType[] aggregateEntities)
{
if (aggregateEntities == null || aggregateEntities.Length == 0)
{
throw new ArgumentNullException("aggregateEntities");
}
_aggregateRoot = aggregateRoot;
_aggregateEntities = aggregateEntities;
}
开发者ID:YuryBaranikhin,项目名称:nuclear-aggregates-layer,代码行数:10,代码来源:AggregateDescriptor.cs
示例17: BuildDelegate
private Func<IValueReader, object> BuildDelegate(IEntityType entityType)
{
var memberMappings = _memberMapper.MapPropertiesToMembers(entityType);
var clrType = entityType.Type;
var readerParameter = Expression.Parameter(typeof(IValueReader), "valueReader");
var instanceVariable = Expression.Variable(clrType, "instance");
var blockExpressions = new List<Expression>
{
Expression.Assign(instanceVariable, Expression.New(clrType.GetDeclaredConstructor(null)))
};
foreach (var mapping in memberMappings)
{
var propertyInfo = mapping.Item2 as PropertyInfo;
var fieldInfo = mapping.Item2 as FieldInfo;
var targetType = propertyInfo != null
? propertyInfo.PropertyType
: fieldInfo.FieldType;
var indexExpression = Expression.Constant(mapping.Item1.Index);
Expression callReaderExpression = Expression.Call(
readerParameter,
_readValue.MakeGenericMethod(targetType),
indexExpression);
if (targetType.IsNullableType())
{
callReaderExpression = Expression.Condition(
Expression.Call(readerParameter, _isNull, indexExpression),
Expression.Constant(null, targetType),
callReaderExpression);
}
if (propertyInfo != null)
{
blockExpressions.Add(
Expression.Assign(Expression.Property(instanceVariable, propertyInfo),
callReaderExpression));
}
else
{
blockExpressions.Add(
Expression.Assign(Expression.Field(instanceVariable, fieldInfo),
callReaderExpression));
}
}
blockExpressions.Add(instanceVariable);
return Expression.Lambda<Func<IValueReader, object>>(Expression.Block(new[] { instanceVariable }, blockExpressions), readerParameter).Compile();
}
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:55,代码来源:EntityMaterializerSource.cs
示例18: StateEntry
protected StateEntry(
[NotNull] DbContextConfiguration configuration,
[NotNull] IEntityType entityType)
{
Check.NotNull(configuration, "configuration");
Check.NotNull(entityType, "entityType");
_configuration = configuration;
_entityType = entityType;
_stateData = new StateData(entityType.Properties.Count);
}
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:11,代码来源:StateEntry.cs
示例19: NewInternalEntityEntry
private InternalEntityEntry NewInternalEntityEntry(IStateManager stateManager, IEntityType entityType, object entity, IValueReader valueReader)
{
if (!entityType.HasClrType())
{
return new InternalShadowEntityEntry(stateManager, entityType, _metadataServices, valueReader);
}
return entityType.ShadowPropertyCount() > 0
? (InternalEntityEntry)new InternalMixedEntityEntry(stateManager, entityType, _metadataServices, entity, valueReader)
: new InternalClrEntityEntry(stateManager, entityType, _metadataServices, entity);
}
开发者ID:thegido,项目名称:EntityFramework,代码行数:11,代码来源:InternalEntityEntryFactory.cs
示例20: StartTrackingFromQuery
public override InternalEntityEntry StartTrackingFromQuery(IEntityType entityType, object entity, ValueBuffer valueBuffer)
{
InTracking = true;
try
{
return base.StartTrackingFromQuery(entityType, entity, valueBuffer);
}
finally
{
InTracking = false;
}
}
开发者ID:nefremov,项目名称:LazyEntityFramework,代码行数:12,代码来源:LazyStateManager.cs
注:本文中的IEntityType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论