Possible Performance Considerations using Linq to SQL Repositories
- by Robert Harvey
I have an ASP.NET MVC application that uses Linq to SQL repositories for all interactions with the database.
To deal with data security, I do trimming to filter data to only those items to which the user has access. This occurs in several places:
Data in list views
Links in a menu bar
A treeview on the left hand side containing links to content
Role-based security
A special security attribute, inheriting from AuthorizeAttribute, that implements content-based authorization on every controller method.
Each of these places instantiates a repository, which opens a Linq to Sql DataContext and accesses the database. So, by my count, each request for a page access opens at least six separate Linq to SQL DataContexts.
Should I be concerned about this from a performance perspective, and if so, what can be done to mitigate it?