當前位置: 首頁>>代碼示例>>C#>>正文


C# Internal.Model類代碼示例

本文整理匯總了C#中Microsoft.EntityFrameworkCore.Metadata.Internal.Model的典型用法代碼示例。如果您正苦於以下問題:C# Model類的具體用法?C# Model怎麽用?C# Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Model類屬於Microsoft.EntityFrameworkCore.Metadata.Internal命名空間,在下文中一共展示了Model類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Microsoft.EntityFrameworkCore.Metadata.Internal.Model類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。