public void GetKeyProperty_ValidEntityType(Type type, string propertyName)
        {
            var key = ConventionsHelpers.GetKeyProperty(type, throwOnError: false);

            Assert.NotNull(key);
            Assert.Equal(key.Name, propertyName);
        }
Пример #2
0
        public override void Apply(IEntityTypeConfiguration entity, ODataModelBuilder model)
        {
            if (entity == null)
            {
                throw Error.ArgumentNull("entity");
            }

            PropertyInfo key = ConventionsHelpers.GetKeyProperty(entity.ClrType);

            if (key != null && !entity.IgnoredProperties.Contains(key))
            {
                entity.HasKey(key);
            }
        }
        public void GetKeyProperty_InValidEntityType(Type type)
        {
            var key = ConventionsHelpers.GetKeyProperty(type, throwOnError: false);

            Assert.Null(key);
        }