本文整理汇总了C#中Mapping.Join方法的典型用法代码示例。如果您正苦于以下问题:C# Mapping.Join方法的具体用法?C# Mapping.Join怎么用?C# Mapping.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapping
的用法示例。
在下文中一共展示了Mapping.Join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateToObject_WhenCalledWithMultipeTablesUsingJoinIsJoinedCorrectly_SetsPropertiesCorrectly
public void GenerateToObject_WhenCalledWithMultipeTablesUsingJoinIsJoinedCorrectly_SetsPropertiesCorrectly()
{
IMapping mapping = new Mapping();
Action<TestClass, List<TestContent>> listSet = ( x, y ) => x.TestContents = y;
mapping.Join( listSet );
mapping.Table<TestClass>( 0 );
mapping.Table<TestContent>( 1 );
var classMapResult = new ClassMapResult
{
Mappings = (Mapping)mapping
};
var mockDataReader = new MockDataReader();
var table = mockDataReader.AddTable( "Length2" );
var contentTable = mockDataReader.AddTable( "Id", "Name" );
mockDataReader.AddRow( table, 1 );
mockDataReader.AddRow( contentTable, 1, "Name1" );
mockDataReader.AddRow( contentTable, 2, "Name2" );
var func = MappingGenerator.Generate<TestClass>( new MockDataReader(), classMapResult );
var result = func( mockDataReader, new Dictionary<MappingEnum, object>
{
{
MappingEnum.Join, new List<object>
{
listSet
}
}
}, new Dictionary<Tuple<int, Type>, Func<IDataRecord, Dictionary<MappingEnum, object>, object>>() );
Assert.AreEqual( 2, result.TestContents.Count );
Assert.AreEqual( "Name1", result.TestContents[ 0 ].Name );
Assert.AreEqual( "Name2", result.TestContents[ 1 ].Name );
}