I tried both your examples, and they completed fine. The first query returned 75 rows; the second one returned 91 rows. I downloaded samples from Scott's page, opened his DynamicQuery project, and modified the
Main()
as follows:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Linq.Dynamic;
using System.Windows.Forms;
using NorthwindMapping;
namespace Dynamic
{
class Program
{
static void Main(string[] args)
{
Northwind db = new Northwind("Data Source=localhost;Initial Catalog=northwind;Integrated Security=SSPI;");
List<string> paramsList = new List<string> { "CustomerID" };
var customer =
db.Customers.
Select("new(" +
string.Join(", ", paramsList.ToArray()) +
")");
var count = 0;
foreach (var x in customer) {
Console.WriteLine(x);
count++;
}
Console.WriteLine("Returned {0} customers", count);
Console.ReadLine();
}
}
}
This code ran to completion with no errors, with
Where
clause commented and uncommented.
Are we running different versions of his System.Linq.Dynamic? I was unable to locate the code that would produce the error message that you reported in Scott's implementation.