asp.net mvc - .NET - Efficient collection of database entities? -


i have page class , pagecollection class in 3d party orm framework. can fill pagecollection based on parameters (pageid, parentid, url etc..) (sql query). need data multiple times around asp.net mvc website (sitemap, authentication), chose load pages 1 time , reference (global) collection.

globalclass.pages //is pagecollection containing pages 

i have created functions return temporary subcollection or single entity based on parameters mentioned before (pageid, parentid, url etc..).

globalclass.pages.getbypageid(id) //returns single page entity globalclass.pages.getbyparentid(parentid) //returns subcollection 

the site got slow.

what way go here?

  • cache subcollections (getbyparent())?
  • create internal hash-lookup tables collection?
  • something else...?

namespace bll public class pagecollection     inherits customcollectionbase      public sub new()      end sub       public sub loadbyparent(byval pagparent integer)         if pagparent = 0             me.whereadd('parent null')         else             me.whereadd('parent = ' & pagparent.tostring())         end if          me.load(me.data)     end sub      public function getbysitemapnode(byval node sitemapnode) bll.page         return me.getbyurl(node.url)     end function      public function getbyid(byval id integer) bll.page         each p in me             if p.pagautokey = id return p         next         return nothing     end function      public function getbyurl(byval url string) bll.page         each p in me             if p.url = url return p         next         return nothing     end function      public function getbyparent(byval parent integer) bll.pagecollection         dim pc new pagecollection         each p in me             if p.pagparent = parent pc.add(p)         next         return pc     end function end class end namespace 

the first thing determine why site slow. if had dollar every time assumed cause of poor performance , turned out else...

set trace points throughout code , figure out you're spending time. current approach may fine getting hung on implementation detail. fix know broken.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -