I am trying to put a load of data into a table in which the data comes in a name, the ValueCollection key In the form of value for the name and the value as the column,
I need to convert all the values into their correct datatypes, but there is not a good way to do this, think about it and Then insert the columns' ed table in linq
transaction DataToint DB = New Transaction DatatyText (); Var column = db Mapping Mapping Source .GetModel (TransactionDataContext) .GetMetaType (Typographic). DataMember; Type T; String type name, colName; Transaction trans = new transaction (); For (int i = 0; i & lt; column; calculation (); i ++) {if (column [i] .name (nvcRequest.Keys)) {colName = columnNames [i] .name; T = columnname [i]. type; Type name = t. Name Toaster (). ToLower (); Switch (typename) {case "int": // convert to value int and add it to a new transaction / but i can not [columns [i]] = new typed value unfortunately .. - what can i do ? break; Convert case "datetime": // datetime and add new transaction brakes to the appropriate field; }}
etc ... .. ..
db.SubmitChanges ();
The function is in:
in the public stable boole (this object o, ii amerable c) {foreach (object i in c) {if (i.Equals (o )) If true; } return false; }
Any ideas? Maybe I should just build a string query? I do not expect: (
Any help was greatly appreciated
nat
Take a look
Edit:
Depending on your comment below, if you have transaction
object, and one With the values of the word & lt; string, object & gt;
and you want to set the properties of the object with values from the dictionary, you can
Foreach (myTransactionObject.GetType in PropertyInfo myPropertyInfo () .GetProperties ()) {myPropertyInfo.SetValue (myTransacti OnObject, Convert.ChangeType (aPropertyValue, myPropertyInfo.PropertyType), tap);}
No comments:
Post a Comment