public ExpressionEntityValueAccessor(IEntityMetadata entity) { _entity = entity; var param = Expression.Parameter(typeof(object), "p"); var isOfTypeExpression = Expression.Lambda <Func <object, bool> >( Expression.TypeIs(param, entity.ClrType), param); _isOfTypeDelegate = isOfTypeExpression.Compile(); _primaryKeys = entity.GetProperties().Where(p => p.IsPrimaryKey).ToList(); if (_primaryKeys.Count == 1) { _keyType = _primaryKeys[0].PropertyType; } else if (_primaryKeys.Count > 1) { var keyTypes = _primaryKeys.Select(p => p.PropertyType).ToArray(); _keyType = EntityKey.Get(keyTypes); _createEntityKeyDelegate = GetCreateEntityKeyDelegate(_keyType); } if (_primaryKeys.Count > 0) { this._keyEqualsDelegate = GetKeyEqualsDelegate(_entity.ClrType, _primaryKeys); } }
public EntityMetadataBuilder Entity(Type clrType) { return(Entity(EntityKey.Get(clrType))); }
public EntityMetadataBuilder <TEntity> Entity <TEntity>() where TEntity : class { return(new EntityMetadataBuilder <TEntity>(Entity(EntityKey.Get <TEntity>()))); }