What are the pros/cons of choosing between static and instance data access classes in a web app?

前端 未结 4 1128
清歌不尽
清歌不尽 2021-02-05 14:05

I\'ve read several other questions on this topic (here, here, and here), but have yet to see a great answer. I\'ve developed my fair share of data access layers before and perso

4条回答
  •  孤独总比滥情好
    2021-02-05 14:34

    I have been using a static DAL for years, and I agree with your concerns. Threading and concurrency is the most challenging and in my case I store different connection objects in thread static structures. It has proven to be very scalable and performs well, even more so now that I am converting PropertyInfo into PropertyDescriptor which gives me the same benefits of reflection with better performance. In my DAL I simply have to write:

     List tableRows = SQL.Read(new SearchCriteria(), new Table());
    

    Everything spawns off the SQL static class, and that makes my code a lot simpler.

提交回复
热议问题