Esempio n. 1
0
 private static void testPrimaryKey(IMutableEntityType entity, bool hasPrimaryKey)
 {
     if (hasPrimaryKey)
     {
         Assert.IsNotNull(entity.FindPrimaryKey());
     }
     else
     {
         Assert.IsNull(entity.FindPrimaryKey());
     }
 }
        private static List <PrimaryKeyDefinition> GetPrimaryKeyDefinition(IMutableEntityType entityType)
        {
            var keyProperties = entityType.FindPrimaryKey().Properties;
            var foreignKeys   = entityType.GetForeignKeys().SelectMany(i => i.Properties);

            return(keyProperties.Select(i => new PrimaryKeyDefinition()
            {
                Name = i.Name,
                Type = i.ClrType,
                IsPrimaryAndForeign = foreignKeys.Select(j => j.Name).Contains(i.Name)
            }).ToList());
        }
Esempio n. 3
0
        private static void testPrimaryKey(IMutableEntityType entity, params string[] values)
        {
            var key = entity.FindPrimaryKey();

            if (values is null)
            {
                Assert.IsNull(key);
            }
            else
            {
                foreach (var v in values)
                {
                    Assert.IsNotNull(key.Properties.FirstOrDefault(x => x.Name == v));
                }
            }
        }
Esempio n. 4
0
            static void testKey <T>(IMutableEntityType entity, params Expression <Func <T, object> >[] values)
            {
                var key = entity.FindPrimaryKey();

                if (values is null)
                {
                    Assert.IsNull(key);
                }
                else
                {
                    foreach (var v in values)
                    {
                        var name = GetMember.Name(v);
                        Assert.IsNotNull(key.Properties.FirstOrDefault(x => x.Name == name));
                    }
                }
            }