I've converted some code from vb.net to c# but it's having problems with a lambda.
error CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
Here's the translated code..
dynamic ds = (JArray)o["Tables"][0]["Rows"];
using(var connection = new SqlConnection(cnnString))
{connection.Open();
ds.Select(ja =>
connection.Execute("INSERT INTO dbo.AddPlay(UserId, Timestamp, YoutubeId, Source, PlayCount, Rating) " +
" VALUES(ja(0).Value<string>(), ja(1).Value<string>() ja(2).Value<string>(), ja(3).Value<string>(), GetInt(ja(4)), GetInt(ja(5)))"));
}
Select()
isn't for replacing aforeach
loop. – InterlanguageSelect
ispublic static IEnumerable<TResult> Select<TSource, TResult>( this IEnumerable<TSource> source, Func<TSource, TResult> selector )
. If you aren't using/needing the resultIEnumerable<TResult>
then it is probably the wrong operation. – Interlanguage