public static void InsertWsdiResult(AppDefinition appdef)
{
if(appdef.Id == null)
throw new ArgumentNullException("appdef.Id");
foreach (var connector in appdef.WSDIConnectors)
{
foreach (var token in connector.DataMapOperations)
{
using (DbCommand cmd = new CommandBuilder()
.SetCommandText("IQ_InsertWsdiTokens")
.SetCommandType(CommandType.StoredProcedure)
.AddInputParameter("@AppID", appdef.Id)
.AddInputParameter("@FieldID", token.To.Id)
.AddInputParameter("@Expression", token.Expression.Code)
.ToDbCommand())
{
cmd.ExecuteNonQuery();
}
}
}
}
How to use linq query in above code instead of two foreach loops
Thanks
Gokhul VarmanPosted Aug 4, 2017, 12:04 PM
Nilesh ShahPosted Aug 4, 2017, 11:36 AM
What you can do is create the objects for table in which you want to insert, then insert all at once, instead of inserting in a for loop.
but I think you will still need for loop for creating the required objects.