Satish

Satish

  • NA
  • 184
  • 99k

Linq query instead of foreach loop

Aug 4 2017 1:53 AM
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<Guid>("@AppID", appdef.Id)
.AddInputParameter<Guid?>("@FieldID", token.To.Id)
.AddInputParameter<string>("@Expression", token.Expression.Code)
.ToDbCommand())
{
cmd.ExecuteNonQuery();
}
}
}
}
 
How to use linq query in above code instead of two foreach loops
Thanks 

Answers (2)