本文整理汇总了C#中DbPropertyValues.SetValues方法的典型用法代码示例。如果您正苦于以下问题:C# DbPropertyValues.SetValues方法的具体用法?C# DbPropertyValues.SetValues怎么用?C# DbPropertyValues.SetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbPropertyValues
的用法示例。
在下文中一共展示了DbPropertyValues.SetValues方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Calling_SetValues_with_dictionary_of_derived_type_works
public void Calling_SetValues_with_dictionary_of_derived_type_works()
{
var fromProperties = new Dictionary<string, object>
{
{ "Id", 1 }
};
var fromValues = new DbPropertyValues(new TestInternalPropertyValues<FakeDerivedTypeWithProps>(fromProperties));
var toProperties = new Dictionary<string, object>
{
{ "Id", 0 }
};
var toValues = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(toProperties));
toValues.SetValues(fromValues);
Assert.Equal(1, toValues["Id"]);
}
示例2: SetValues_when_nested_dictionary_is_for_wrong_type_throws
public void SetValues_when_nested_dictionary_is_for_wrong_type_throws()
{
var fromProperties = new Dictionary<string, object>
{
{ "Id", 1 }
};
var fromValues = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(fromProperties));
var toProperties = new Dictionary<string, object>
{
{ "Id", 0 }
};
var toValues = new DbPropertyValues(new TestInternalPropertyValues<FakeDerivedTypeWithProps>(toProperties));
Assert.Equal(
Strings.DbPropertyValues_AttemptToSetValuesFromWrongType(
typeof(FakeTypeWithProps).Name, typeof(FakeDerivedTypeWithProps).Name),
Assert.Throws<ArgumentException>(() => toValues.SetValues(fromValues)).Message);
}
示例3: Non_Generic_DbPropertyValues_SetValues_with_a_dictionary_works_on_the_underlying_dictionary
public void Non_Generic_DbPropertyValues_SetValues_with_a_dictionary_works_on_the_underlying_dictionary()
{
var fromValues = new DbPropertyValues(CreateSimpleValues());
fromValues["Id"] = 1;
var toValues = new DbPropertyValues(CreateSimpleValues());
toValues.SetValues(fromValues);
Assert.Equal(1, toValues["Id"]);
}
示例4: Attempt_to_copy_values_from_null_dictionary_on_non_generic_DbPropertyValues_throws
public void Attempt_to_copy_values_from_null_dictionary_on_non_generic_DbPropertyValues_throws()
{
var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>());
Assert.Equal("propertyValues", Assert.Throws<ArgumentNullException>(() => values.SetValues(null)).ParamName);
}
示例5: Calling_SetValues_with_instance_of_derived_type_works
public void Calling_SetValues_with_instance_of_derived_type_works()
{
var properties = new Dictionary<string, object>
{
{ "Id", 0 }
};
var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(properties));
values.SetValues(
new FakeDerivedTypeWithProps
{
Id = 1
});
Assert.Equal(1, values["Id"]);
}
示例6: Non_Generic_DbPropertyValues_SetValues_works_on_the_underlying_dictionary
public void Non_Generic_DbPropertyValues_SetValues_works_on_the_underlying_dictionary()
{
var properties = new Dictionary<string, object>
{
{ "Id", 0 }
};
var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(properties));
values.SetValues(
new FakeTypeWithProps
{
Id = 1
});
Assert.Equal(1, values["Id"]);
}
示例7: Attempt_to_copy_values_from_null_object_throws
public void Attempt_to_copy_values_from_null_object_throws()
{
var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>());
Assert.Equal("obj", Assert.Throws<ArgumentNullException>(() => values.SetValues((object)null)).ParamName);
}