• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Internal.Model类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.EntityFrameworkCore.Metadata.Internal.Model的典型用法代码示例。如果您正苦于以下问题:C# Model类的具体用法?C# Model怎么用?C# Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Model类属于Microsoft.EntityFrameworkCore.Metadata.Internal命名空间,在下文中一共展示了Model类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Can_set_ClrType

        public void Can_set_ClrType()
        {
            var entityType = new Model().AddEntityType(typeof(object));
            var property = entityType.AddProperty("Kake", typeof(string));

            Assert.Equal(typeof(string), property.ClrType);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:7,代码来源:PropertyTest.cs


示例2: Delegate_getter_is_returned_for_IProperty_property

        public void Delegate_getter_is_returned_for_IProperty_property()
        {
            var entityType = new Model().AddEntityType(typeof(Customer));
            var idProperty = entityType.AddProperty("Id", typeof(int), shadow: false);

            Assert.Equal(7, new ClrPropertyGetterFactory().Create(idProperty).GetClrValue(new Customer { Id = 7 }));
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:7,代码来源:ClrPropertyGetterFactoryTest.cs


示例3: Change_tracking_strategy_can_be_changed

        public void Change_tracking_strategy_can_be_changed()
        {
            var model = new Model { ChangeTrackingStrategy = ChangeTrackingStrategy.ChangingAndChangedNotifications };
            Assert.Equal(ChangeTrackingStrategy.ChangingAndChangedNotifications, model.ChangeTrackingStrategy);

            model.ChangeTrackingStrategy = ChangeTrackingStrategy.ChangedNotifications;
            Assert.Equal(ChangeTrackingStrategy.ChangedNotifications, model.GetChangeTrackingStrategy());
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:8,代码来源:ModelTest.cs


示例4: Model_can_be_set_explicitly_in_options

        public void Model_can_be_set_explicitly_in_options()
        {
            var model = new Model();

            var optionsBuilder = new DbContextOptionsBuilder().UseModel(model);

            Assert.Same(model, optionsBuilder.Options.FindExtension<CoreOptionsExtension>().Model);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:8,代码来源:DbContextOptionsTest.cs


示例5: Can_get_model

        public void Can_get_model()
        {
            var model = new Model();

            var sequence = Sequence.GetOrAddSequence(model, RelationalFullAnnotationNames.Instance.SequencePrefix, "Foo");

            Assert.Same(model, sequence.Model);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:8,代码来源:SequenceTest.cs


示例6: CreateForeignKey

 private ForeignKey CreateForeignKey()
 {
     var model = new Model();
     var entityType = model.AddEntityType(typeof(E));
     var idProperty = entityType.AddProperty("id", typeof(int));
     var key = entityType.SetPrimaryKey(idProperty);
     var fkProperty = entityType.AddProperty("p", typeof(int));
     return entityType.AddForeignKey(fkProperty, key, entityType);
 }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:9,代码来源:NavigationTest.cs


示例7: M_underscore_matching_field_is_not_used_if_type_is_not_compatible

        public void M_underscore_matching_field_is_not_used_if_type_is_not_compatible()
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSideOfTheMoon));
            var property = entityType.AddProperty("SpeakToMe", typeof(int), shadow: false);
            var propertyInfo = entityType.ClrType.GetAnyProperty("SpeakToMe");
            var fields = propertyInfo.DeclaringType.GetRuntimeFields().ToDictionary(f => f.Name);

            Assert.Null(new FieldMatcher().TryMatchFieldName(property, propertyInfo, fields));
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:9,代码来源:FieldMatcherTest.cs


示例8: Sensitive_data_logging_can_be_set_explicitly_in_options

        public void Sensitive_data_logging_can_be_set_explicitly_in_options()
        {
            var model = new Model();

            var optionsBuilder = new DbContextOptionsBuilder().UseModel(model).EnableSensitiveDataLogging();

            Assert.Same(model, optionsBuilder.Options.FindExtension<CoreOptionsExtension>().Model);
            Assert.True(optionsBuilder.Options.FindExtension<CoreOptionsExtension>().IsSensitiveDataLoggingEnabled);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:9,代码来源:DbContextOptionsTest.cs


示例9: Constructor_validates_properties_from_same_entity

        public void Constructor_validates_properties_from_same_entity()
        {
            var property1 = new Model().AddEntityType(typeof(Customer)).GetOrAddProperty(Customer.IdProperty);
            var property2 = new Model().AddEntityType(typeof(Order)).GetOrAddProperty(Order.IdProperty);

            Assert.Equal(CoreStrings.IndexPropertiesWrongEntity($"{{'{property1.Name}', '{property2.Name}'}}", typeof(Customer).Name),
                Assert.Throws<InvalidOperationException>(
                    () => property1.DeclaringEntityType.AddIndex(new[] { property1, property2 })).Message);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:9,代码来源:IndexTest.cs


示例10: Does_not_detect_duplicate_table_names_for_inherited_entities

        public virtual void Does_not_detect_duplicate_table_names_for_inherited_entities()
        {
            var model = new Model();
            var entityA = model.AddEntityType(typeof(A));
            SetPrimaryKey(entityA);
            var entityC = model.AddEntityType(typeof(C));
            SetBaseType(entityC, entityA);

            Validate(model);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:10,代码来源:RelationalModelValidatorTest.cs


示例11: Throws_if_no_match_found_and_no_property_setter

        public void Throws_if_no_match_found_and_no_property_setter()
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSide));
            var property = entityType.AddProperty(TheDarkSide.TimeProperty);

            Assert.Equal(
                CoreStrings.NoFieldOrSetter(typeof(TheDarkSide).FullName, "Time"),
                Assert.Throws<InvalidOperationException>(
                    () => new MemberMapper(new FieldMatcher()).MapPropertiesToMembers(entityType)).Message);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:10,代码来源:MemberMapperTest.cs


示例12: CreateModel

        private static Model CreateModel(bool generateValues = true)
        {
            var model = new Model();

            var entityType = model.AddEntityType("Led");
            entityType.AddProperty("Zeppelin", typeof(Guid));
            entityType.AddProperty("Stairway", typeof(Guid)).RequiresValueGenerator = generateValues;

            return model;
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:10,代码来源:ValueGeneratorCacheTest.cs


示例13: Validates_properties_from_same_entity

        public void Validates_properties_from_same_entity()
        {
            var entityType1 = new Model().AddEntityType(typeof(Customer));
            var entityType2 = new Model().AddEntityType(typeof(Order));
            var property1 = entityType1.GetOrAddProperty(Customer.IdProperty);
            var property2 = entityType2.GetOrAddProperty(Order.NameProperty);

            Assert.Equal(CoreStrings.KeyPropertiesWrongEntity($"{{'{property1.Name}', '{property2.Name}'}}", entityType1.DisplayName()),
                Assert.Throws<InvalidOperationException>(
                    () => entityType1.AddKey(new[] { property1, property2 })).Message);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:11,代码来源:KeyTest.cs


示例14: FieldMatchTest

        private static void FieldMatchTest(string propertyName, string fieldName)
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSideOfTheMoon));
            var property = entityType.AddProperty(propertyName, typeof(int), shadow: false);
            var propertyInfo = entityType.ClrType.GetAnyProperty(propertyName);
            var fields = propertyInfo.DeclaringType.GetRuntimeFields().ToDictionary(f => f.Name);

            var matchedField = new FieldMatcher().TryMatchFieldName(property, propertyInfo, fields);

            Assert.Equal(fieldName, matchedField.Name);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:11,代码来源:FieldMatcherTest.cs


示例15: Default_nullability_of_property_is_based_on_nullability_of_CLR_type

        public void Default_nullability_of_property_is_based_on_nullability_of_CLR_type()
        {
            var entityType = new Model().AddEntityType(typeof(object));
            var stringProperty = entityType.AddProperty("stringName", typeof(string));
            var nullableIntProperty = entityType.AddProperty("nullableIntName", typeof(int?));
            var intProperty = entityType.AddProperty("intName", typeof(int));

            Assert.True(stringProperty.IsNullable);
            Assert.True(nullableIntProperty.IsNullable);
            Assert.False(intProperty.IsNullable);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:11,代码来源:PropertyTest.cs


示例16: Property_added_by_name_is_non_shadow_if_matches_Clr_property

        public void Property_added_by_name_is_non_shadow_if_matches_Clr_property()
        {
            var model = new Model();
            var modelBuilder = new InternalModelBuilder(model);
            var entityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit);
            var builder = entityBuilder.Property(Customer.NameProperty.Name, ConfigurationSource.Convention);
            var property = builder.Metadata;

            Assert.Equal(typeof(string), property.ClrType);
            Assert.False(property.IsShadowProperty);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:11,代码来源:InternalPropertyBuilderTest.cs


示例17: Property_setter_is_used_if_no_matching_field_is_found

        public void Property_setter_is_used_if_no_matching_field_is_found()
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSide));
            var property = entityType.AddProperty(TheDarkSide.OnTheRunProperty);

            var mapping = new MemberMapper(new FieldMatcher()).MapPropertiesToMembers(entityType).Single();

            Assert.Same(property, mapping.Item1);
            Assert.IsAssignableFrom<PropertyInfo>(mapping.Item2);
            Assert.Equal("OnTheRun", mapping.Item2.Name);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:11,代码来源:MemberMapperTest.cs


示例18: Field_name_match_is_used_in_preference_to_property_setter

        public void Field_name_match_is_used_in_preference_to_property_setter()
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSide));
            var property = entityType.AddProperty(TheDarkSide.BreatheProperty);

            var mapping = new MemberMapper(new FieldMatcher()).MapPropertiesToMembers(entityType).Single();

            Assert.Same(property, mapping.Item1);
            Assert.IsAssignableFrom<FieldInfo>(mapping.Item2);
            Assert.Equal("_breathe", mapping.Item2.Name);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:11,代码来源:MemberMapperTest.cs


示例19: Throws_if_annotated_field_name_is_not_found

        public void Throws_if_annotated_field_name_is_not_found()
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSide));
            var property = entityType.AddProperty(TheDarkSide.SpeakToMeProperty);
            property["BackingField"] = "_speakToMe";

            Assert.Equal(
                CoreStrings.MissingBackingField(typeof(TheDarkSide).FullName, "SpeakToMe", "_speakToMe"),
                Assert.Throws<InvalidOperationException>(
                    () => new MemberMapper(new FieldMatcher()).MapPropertiesToMembers(entityType)).Message);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:11,代码来源:MemberMapperTest.cs


示例20: Throws_if_annotated_field_if_types_not_compatible

        public void Throws_if_annotated_field_if_types_not_compatible()
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSide));
            var property = entityType.AddProperty(TheDarkSide.SpeakToMeProperty);
            property["BackingField"] = "_badFieldForSpeak";

            Assert.Equal(
                CoreStrings.BadBackingFieldType("_badFieldForSpeak", typeof(string).Name, typeof(TheDarkSide).FullName, "SpeakToMe", typeof(int).Name),
                Assert.Throws<InvalidOperationException>(
                    () => new MemberMapper(new FieldMatcher()).MapPropertiesToMembers(entityType)).Message);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:11,代码来源:MemberMapperTest.cs



注:本文中的Microsoft.EntityFrameworkCore.Metadata.Internal.Model类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Data.EwsServiceXmlWriter类代码示例发布时间:2022-05-26
下一篇:
C# Utilities.BuildCommand类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap