FormCollectionExtend.MVC
1.0.0
MVC FormCollection을 객체 확장 라이브러리로.
FormCollection을 개체로 쉽게 변환합니다.
UnitTest 예제를 확인하려면 여기를 클릭하세요.
FormCollection을 단일 개체로 변환합니다.
// Arrange
FormCollection Stub = CreateTestData ( ) ;
// Act
TestModel Test = Stub . ToSingleObject < TestModel > ( ) ;
매핑 사전을 사용하여 FormCollection을 단일 개체로 변환합니다.
// Arrange
FormCollection Stub = CreateTestDataWithDifferentNaming ( ) ;
Dictionary < string , string > MappingDictionary = CreateMappingDictionary ( ) ;
// Act
TestModel Test = Stub . ToSingleObject < TestModel > ( MappingDictionary ) ;
FormCollection을 List
// Arrange FormCollection Stub = CreateTestDataSet ( ) ; string PrimaryKeyName = "Name" ; // Act List < TestModel > Test = Stub . ToListObject < TestModel > ( PrimaryKeyName ) ;
매핑 사전을 사용하여 FormCollection을 List
// Arrange FormCollection Stub = CreateTestDataSetWithDifferentNaming ( ) ; Dictionary < string , string > MappingDictionary = CreateMappingDictionary ( ) ; string PrimaryKeyName = "Name111" ; // Act List < TestModel > Test = Stub . ToListObject < TestModel > ( MappingDictionary , PrimaryKeyName ) ;
예:
Dictionary < string , string > CreateMappingDictionary ( ) { // Key.Add( "後端物件屬性", "前端表單欄位Name" ); // Key.Add( "Model Object Property", "Form Field Name" ); Dictionary < string , string > Key = new Dictionary < string , string > ( ) ; Key . Add ( "Name" , "Name111" ) ; Key . Add ( "age" , "age222" ) ; Key . Add ( "PhoneNumber" , "PhoneNumber333" ) ; Key . Add ( "Married" , "Married444" ) ; Key . Add ( "CreatedDateTime" , "CreatedDateTime555" ) ; Key . Add ( "ModifyDateTime" , "ModifyDateTime666" ) ; return Key ; }