I have EntityFramework
and LINQ to SQL
background.
I am thinking of using dapper for performance gains.
Dapper caches information about every query it runs, this allow it to materialize objects quickly and process parameters quickly. The current implementation caches this information in a ConcurrentDictionary
object. The objects it stores are never flushed. If you are generating SQL strings on the fly without using parameters it is possible you will hit memory issues. We may convert the dictionaries to an LRU Cache
.
Do I have to parameterized All queries. Even queries which do not have any params.
Example
Select Id,Boo FROM dbo.FOO
There's nothing to vary in your query so, no, you do not need to parameterize it.
The warning is there to tell you that if you write Select Id,Boo FROM dbo.FOO where Bar=3
, Select Id,Boo FROM dbo.FOO where Bar=4
, and Select Id,Boo FROM dbo.FOO where Bar=5
then 3 queries will be cached. And as you continue to vary what you're matching against Bar
, even more copies will be made.