Dapper, list of parameters, possible memory issues

dapper parameters

Question

I'm using dapper and solr. After I get ids from solr I'm quering db like that:

var dbResults = await dbConnection.QueryAsync<Product>(@"SELECT  p.[ProductId] as Id]
                                                                        ,p.[Product] as [Name]
                                                                        ,p.[Price]
                                                                        ,p.[SeoLink]                                                                            
                                                                        ,p.[CategoryId]                                   
                                                            FROM [dbo].[Products] p with(nolock)                                                                
                                                            WHERE p.[ProductId] in @productsIds", new {productsIds = toGet}, commandTimeout: 2);

Count of ids is changing from 1 to 200. Will I have memory issues because every query will be cached separately? Any ideas how can I optimize it? (I'm using azure website with sql azure and I'm getting 500 internal server error from time to time without any reason, nothing in logs.)

Accepted Answer

Well, at the .NET side we only cache that once per text / connection-string pair, where "text" here is the fixed TSQL query before any voodoo. The generated IL for that scenario includes a call to PackListParameters (which is after all the cache steps etc - just before exec), which adds the multiple parameters and changes the TSQL.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why