This is actually not the answer, and I'm going to make it a comment, but you need more space for the code snippet.
Judging by the SubSonic code, I'm sure that in some cases when you get errors that are not supported by the constructor, SS for some reason tries to parse your new ...() statement in SQL. The insult method is part of the SQL Formatter and looks like it is processing a DateTime:
protected override NewExpression VisitNew(NewExpression nex) { if (nex.Constructor.DeclaringType == typeof(DateTime)) { // ...omitted for brevity... } throw new NotSupportedException(string.Format("The construtor '{0}' is not supported", nex.Constructor)); }
I think this is normal if you did something like:
someData .Where (data => data.CreatedDate <= new DateTime (2011, 12, 01)). Select (data => data)
Then newDateTime will be translated into SQL. Therefore, however, you change Linq to get this exception, I think this is what happens. I assume this is because if you added .OrderBy() after .Select() , then you no longer call OrderBy in IQueryable from the fact that AllItems () is returned, but instead try to arrange what is returned. Select (), which is enumerated for new qualities, so SS is probably trying to turn all this into SQL.
I am wondering if this will work correctly if you cancel it?
AllItems().Where(c => c.Id== id) .OrderBy(d => d.QualityType) .Select(d => new Quality(d.QualityType));
source share