simmotech wrote:
You don't want to do that, no parameters opens the door for SQL injection, and defies the entire concept.
Not sure what you need here, are you talking about returning the TOP xxx records?
I don't think SQL injection is possible in this scenario since the output is numbers, not strings and under control of the application. (Interested to learn if that isn't correct though).
that would indeed be hard to do, unless the numbers are stored as strings somewhere.
I have a query. It is fairly large so I won't post it here unless you think it would help.
Its WHERE clause is something like this:-
.Where(CommissionItemFields.ID == commissionStatementIDs)
thus creating a FieldCompareRangePredicate.
commissionStatementIDs is an int[] that gets passed to the method creating/running the query. Sometimes the array is small and sometimes it has a length of 6000.
If it happens to be >2100 then the method will crash because SQL Server only supports that number of parameters as a maximum.
If the query was written to include "IN (1, 2, 3, ..., 6000) rather than use 6000 parameters then it works since the 2100 limit doesn't apply.
You could create your own fieldcompare range predicate, which inlines the values instead of creating parameters and use that, that would solve it for you. There's no built-in way to do what you want, it requires a custom predicate (which is easy to create).
After the query is created, I would ideally like to keep the same, simple fetch code but with a parameter telling LLBLGen to automatically do any paging necessary in xxx row chunks - say 2000.
using (var adapter = new DataAccessAdapter())
{
return adapter.FetchQuery(query, 2000);
}
I don't believe this is possible but I thought I'd ask in case I'd missed something.
can't you use normal paging for that?
Another workaround which would still avoid SQL Injection would be to use a temporary table but I don't believe LLBLGen can support that?
Inserts in temp tables, no you have to formulate the query yourself then, as the temp table target is not settable using entities, you have to update the generated query to specify the temptable instead of the table generated into the query.