Possible Performance Considerations using Linq to SQL Repositories
        Posted  
        
            by Robert Harvey
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Robert Harvey
        
        
        
        Published on 2010-03-26T20:05:14Z
        Indexed on 
            2010/03/26
            20:13 UTC
        
        
        Read the original article
        Hit count: 333
        
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?
© Stack Overflow or respective owner