Application Foundation
An application I work has architecture in a way where we have a Class object that represents each table. So for example we might have a “Customer” table in the database. So our class would be something like..
Customer.vb class file…
Private _FirstName AsString = String.Empty
PublicProperty FirstName() AsString
Get
Return _FirstName
EndGet
Set(ByVal value AsString)
_FirstName = value
EndSet
EndProperty
Private _LastName AsString = String.Empty
PublicProperty LastName() AsString
Get
Return _LastName
EndGet
Set(ByVal value AsString)
_LastName = value
EndSet
EndProperty
EndClass
In this class is a function to say list all customers, we call this “GetList” method. You might use another way to bring back a list of data. Ideally now we’d want to bring back Enumerable Lists, but the app was already structured for DataSets and DataTables. So I was trying to reuse what we had.
Customer.vb class file
Dim oDS As Data.DataSet
Try
oDS = DataAccess.SqlHelper.ExecuteDataset(_ConnectionString, Data.CommandType.StoredProcedure, "CustomerGetList")
Return oDS.Tables(0)
Catch ex As Exception
Throw ex
Finally
oDS = Nothing
EndTry
EndFunction
So on our pages we might do something like this…
Default.aspx.vb
Dim oCustomer AsNew Customer
oCustomer.FirstName = "Fred"
oCustomer.LastName = "Mastro"
oCustomer.SaveToDB()
GridView1.DataSource = oCustomer.GetList()
GridView1.DataBind()
oCustomer = Nothing
EndSub
And this returns a nice DataTable and populates the grid. Great!
Problem Areas over WCF to SliverLight
I was working on a SilverLight application that would talk to an existing business application, to pull back and list records. I had to use a Service, so I went with WCF since RIA.Net is not in production yet. The problem was that DataTables can not be serialized and set over WCF to SilverLight. So I tried messing with Linq to SQL to pull data back and populate classes I already had, but LinqTables are not serializable either, and instead of modifying all the Linq classes generated in my class I wanted to find an easier solution.
DataTable to List(Of Customer) Solution
I can across these two posts: Datatable to List of Objects Mapper and Creating datarow to object mapper and was amazed. Using reflection Chris Rock (lol) was able to read the properties of the object and map each column of the datatable to the desired property of the object. This is what I’m looking to do. This would manually mimic Linq type functionality. The Bulk of the code is this
My Helper.vb class file
- PublicClass Helper
- PublicFunction MapDatarowToObject(Of T)(ByVal dr As DataRow) As T
- Try
- If dr IsNothingThen
- ReturnNothing
- EndIf
- Dim instance As T = Activator.CreateInstance(Of T)()
- Dim properties() As Reflection.PropertyInfo = instance.GetType().GetProperties()
- If (properties.Length > 0) Then
- ForEach propertyObject As Reflection.PropertyInfo In properties
- Dim valueSet AsBoolean = False
- ForEach attributeObject AsObjectIn propertyObject.GetCustomAttributes(False)
- If attributeObject.GetType() IsGetType(MapperColumn) Then
- Dim columnAttributeObject As MapperColumn = CType(attributeObject, MapperColumn)
- If (columnAttributeObject.ColumnName <> String.Empty) Then
- If dr.Table.Columns.Contains(columnAttributeObject.ColumnName) AndAlsoNot dr(columnAttributeObject.ColumnName) Is DBNull.Value Then
- propertyObject.SetValue(instance, dr(columnAttributeObject.ColumnName), Nothing)
- valueSet = True
- EndIf
- EndIf
- EndIf
- Next
- IfNot valueSet Then
- If dr.Table.Columns.Contains(propertyObject.Name) AndAlsoNot dr(propertyObject.Name) Is DBNull.Value Then
- propertyObject.SetValue(instance, dr(propertyObject.Name), Nothing)
- EndIf
- EndIf
- Next
- EndIf
- Return instance
- Catch ex As Exception
- Throw ex
- EndTry
- EndFunction
- PublicFunction MapDataTableToList(Of T)(ByVal dt As DataTable) As Collections.Generic.IList(Of T)
- If dt IsNothingThen
- ReturnNothing
- EndIf
- Dim list As IList(Of T) = New List(Of T)
- ForEach dr As DataRow In dt.Rows
- list.Add(MapDatarowToObject(Of T)(dr))
- Next
- Return list
- EndFunction
- EndClass
- <AttributeUsage(AttributeTargets.Property)> _
- PublicClass MapperColumn
- Inherits Attribute
- Private mColumnName AsString
- PublicSubNew(ByVal columnName AsString)
- mColumnName = columnName
- EndSub
- PublicProperty ColumnName() AsString
- Get
- Return mColumnName
- EndGet
- Set(ByVal value AsString)
- mColumnName = value
- EndSet
- EndProperty
- EndClass
Using Mapper in WCF
Now in my WCF Service methods I can just instantiate Customers like I always do in the normal application and apply the new Mapper method to get a List of the class objects.
WCFServiceMethods.vb file (which is code-behind to WCFServiceMethods.svc)
- Imports System.ServiceModel
- Imports System.ServiceModel.Activation
- Imports System.Runtime.Serialization 'For DataContract
- Imports System.Collections.Generic
- <ServiceContract(Namespace:="")> _
- <ServiceBehavior(IncludeExceptionDetailInFaults:=True)> _
- <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
- PublicClass WCFServiceMethods
- <OperationContract()> _
- PublicFunction GetCustomers() As Collections.Generic.List(Of Customer)
- Dim oCustomer AsNew Customer
- Dim Customers As Collections.Generic.List(Of Customer)
- Customers = Helper.MapDataTableToList(Of Customer)(oCustomer.GetList())
- oCustomer = Nothing
- Return Customers
- EndFunction
- EndClass
You’ll see in Line 15, I can take the DataTable and now create a List(Of Customer) object, which is serializable and send it over the wire.
Applying it in SilverLight or Other Application that uses your WCF Service
Assuming you referenced your WCF Service.. Now on my SilverLight app on a button click I can get the List of Customers and show it natively in a datagrid.
MainPage.xaml code-behind
Dim oWCFProxy AsNew WCFService.WCFServiceClient
AddHandler oWCFProxy.GetCustomers, AddressOf oWCFProxy_GetCustomersCompleted
oWCFProxy.GetCustomersAsync()
oWCFProxy = Nothing
EndSub
PrivateSub oWCFProxy_GetCustomersCompleted(ByVal sender AsObject, ByVal e As WCFService.GetCustomersCompletedEventArgs)
Dim Customers As Collections.ObjectModel.Collection(Of oWCFProxy.Customer)
Customers = e.Result
DataGrid1.ItemsSource = Customers
EndSub
Problem Area With Mapper Casting Types and Solution
So with all that above you should have enough to re-create all this. Read through Chris’ posts because it does a good job of explaining the mapper. I ran into a problem with the mapper though on line 39. Problem is when it tries to map data from the database, it all comes back as a string, and you don’t know until run-time what System.Type you need, so you can’t CType or DirectCast by using System.Type.GetType(), so I had to create a crappy function to Throw ex check every possible combination. This the best way? I sure hope it isn’t. Hope to find a better solution for it but was pressed for time.
So what was my crappy solution? I don’t even want to post it haha. I swapped out line 39 and 28 with the a call to this method of 1531 lines of code.
PrivateSub TryCastTypeToPropertyType(ByRef propertyObject As Reflection.PropertyInfo, ByRef instance AsObject, ByRef dr As DataRow, ByRef ColumnName AsString)
Try
'Try to Default Types
propertyObject.SetValue(instance, dr(ColumnName), Nothing)
Catch exDefault1 As InvalidCastException
Try
'Try to String
propertyObject.SetValue(instance, CType(dr(ColumnName), String), Nothing)
Catch exString1 As InvalidCastException
'Try to Integer
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Integer), Nothing)
Catch exInt32a As ArgumentException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exInt32b As InvalidCastException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exString2 As ArgumentException
'Try to Integer
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Integer), Nothing)
Catch exInt32a As ArgumentException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exInt32b As InvalidCastException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exDefault2 As ArgumentException
Try
'Try to String
propertyObject.SetValue(instance, CType(dr(ColumnName), String), Nothing)
Catch exString1 As InvalidCastException
'Try to Integer
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Integer), Nothing)
Catch exInt32a As ArgumentException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exInt32b As InvalidCastException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exString2 As ArgumentException
'Try to Integer
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Integer), Nothing)
Catch exInt32a As ArgumentException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
Catch exInt32b As InvalidCastException
'Try to DateTime
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), DateTime), Nothing)
Catch exDate1 As ArgumentException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
Catch exDate2 As InvalidCastException
'Try to Decimal
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Decimal), Nothing)
Catch exDecimal1 As ArgumentException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
Catch exDecimal2 As InvalidCastException
'Try to Double
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Double), Nothing)
Catch exDouble1 As ArgumentException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
Catch exDouble2 As InvalidCastException
'Try to Boolean
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Boolean), Nothing)
Catch exBoolean1 As ArgumentException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
Catch exBoolean2 As InvalidCastException
'Try To Date
Try
propertyObject.SetValue(instance, CType(dr(ColumnName), Date), Nothing)
Catch ex As Exception
Throw ex
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
EndTry
End Sub
Maybe I’ll get lucky and someone will post up a “Oh you can just do this, which is new in .Net 3.5 or 4.0.. “ and I can get rid of this thing. But hey it works!
Resource: How to Consume WCF and ASP.Net Web Services in Silverlight