Exemplo n.º 1
0
        internal static object GetPrimaryKeyValue(DbContext context, object entity)
        {
            Microsoft.EntityFrameworkCore.Metadata.IKey key = context.Model.FindEntityType(entity.GetType().FullName).FindPrimaryKey();

            if (key == null)
            {
                return(null);
            }

            return(key.Properties.Select(p => p.PropertyInfo.GetValue(entity)).FirstOrDefault());
        }
Exemplo n.º 2
0
        public Key(Microsoft.EntityFrameworkCore.Metadata.IKey key, IEntityType entityType)
        {
            var keyProperties = new List <IProperty>();

            foreach (var keyProperty in key.Properties)
            {
                keyProperties.Add(entityType.FindProperty(keyProperty.Name));
            }

            Properties = keyProperties;
        }
Exemplo n.º 3
0
 private void SetPrimaryKey(Microsoft.EntityFrameworkCore.Metadata.IKey primaryKey)
 {
     PrimaryKey = new Key(primaryKey, this);
 }