コード例 #1
0
        public void GetMethodChain_returns_chain_when_one_key_property()
        {
            var configuration = new KeyConfiguration { KeyProperties = { new EdmProperty("Id") } };
            var code = new CSharpCodeHelper();

            Assert.Equal(".HasKey(e => e.Id)", configuration.GetMethodChain(code));
        }
コード例 #2
0
        public IConfiguration Discover(EntitySet entitySet, DbModel model)
        {
            Debug.Assert(entitySet != null, "entitySet is null.");
            Debug.Assert(model != null, "model is null.");

            var entityType = entitySet.ElementType;
            var keyProperties = entityType.KeyProperties;
            Debug.Assert(keyProperties.Count != 0, "keyProperties is empty.");

            if (keyProperties.Count == 1 && keyProperties.First().HasConventionalKeyName())
            {
                // By convention
                return null;
            }

            var configuration = new KeyConfiguration();

            foreach (var keyProperty in keyProperties)
            {
                configuration.KeyProperties.Add(keyProperty);
            }

            return configuration;
        }