Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #61 (permalink)  
Old November 16th, 2007, 08:36 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

now the code doesn't seem to be using the cache when i page.

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static List<user> Getusers(string sortExpression, int startRowIndex, int maximumRows)
        {
            List<user> users = null;
            string key = "Department_users_Getusers_" + sortExpression + "_" + startRowIndex + "_" + maximumRows;

            if (Settings.EnableCaching && Cache[key] != null)
            {
                users = (List<user>) Cache[key];
            }
            else
            {
                users =
                    GetuserListFromusersEntityList(
                        SiteProvider.Department.Getusers(sortExpression, startRowIndex, maximumRows));
                CacheData(key, users);
            }

            return users;
        }

even though EnableCaching is true && Cache[key] is not null. Grief!

  #62 (permalink)  
Old November 16th, 2007, 08:41 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the cache count seems to be resetting itself to zero.

Without any code change, it is now using the cache. odd.

seems stable now. pretty cool. uses the cache until the data changes via the application then it requeries the datqabase and re-caches the new data, based on current page.
  #63 (permalink)  
Old November 16th, 2007, 08:58 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by forumuser
seems stable now. pretty cool. uses the cache until the data changes via the application then it requeries the datqabase and re-caches the new data, based on current page.
yes, should do this (hopefully). as i said, that IS the beauty of this, the fact that the objects are only ever used if accessed and only then ever updated if an element that affects the dataset is updated.

happy discoveries!!

jimi

http://www.originaltalent.com
  #64 (permalink)  
Old November 16th, 2007, 12:49 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by forumuser
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static List<user> Getusers(string sortExpression, int startRowIndex, int maximumRows)
        {
            List<user> users = null;
            string key = "Department_users_Getusers_" + sortExpression + "_" + startRowIndex + "_" + maximumRows;

            if (Settings.EnableCaching && Cache[key] != null)
            {
                users = (List<user>) Cache[key];
            }
            else
            {
                users =
                    GetuserListFromusersEntityList(
                        SiteProvider.Department.Getusers(sortExpression, startRowIndex, maximumRows));
                CacheData(key, users);
            }

            return users;
        }
just a little 'tip' on the above method. it's a good idea to assign the Cache[key] to an object BEFORE doing the test. here's why. if you do the test (if (Settings.EnableCaching && Cache[key] != null)) and then again set the list to the Cache[key], you run the risk of the object being changed between testing for it and assigning it. you could re-write the above function with one (well two actually) small change (in blue):

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static List<user> Getusers(string sortExpression, int startRowIndex, int maximumRows)
        {
            List<user> users = null;
            string key = "Department_users_Getusers_" + sortExpression + "_" + startRowIndex + "_" + maximumRows;

            object data = Cache[key];
            if (Settings.EnableCaching && data != null)
            {
                users = (List<user>)data;
            }
            else
            {
                users =
                    GetuserListFromusersEntityList(
                        SiteProvider.Department.Getusers(sortExpression, startRowIndex, maximumRows));
                CacheData(key, users);
            }

            return users;
        }

hope you get my drift.


jimi

http://www.originaltalent.com
  #65 (permalink)  
Old November 18th, 2007, 04:19 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks jimi. another question.
with an employees table of some 15 fields, and the fact that i often need to populate a dropdown list with employees names and their ids, would it be good practice to create a special object that encapsulated just those 2 fields for that explicit purpose?

  #66 (permalink)  
Old November 18th, 2007, 05:28 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by forumuser
 thanks jimi. another question.
with an employees table of some 15 fields, and the fact that i often need to populate a dropdown list with employees names and their ids, would it be good practice to create a special object that encapsulated just those 2 fields for that explicit purpose?
forumuser - nah. just use the default employees object for that purpose and assign the appropriate fields that will be used. i.e. for the forums dropdown, here's the stuff i use:

                        <asp:DropDownList ID="lstForumID" runat="server" SelectedValue='<%# Bind("ForumID") %>' DataSourceID="objForums" DataTextField="Title" DataValueField="ForumID" AppendDataBoundItems="true">
                            <asp:ListItem Value="">-- Please Select --</asp:ListItem>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="objForums" runat="server" SelectMethod="GetForums" TypeName="JB.OriginalTalent.BLL.Posts.Forum"></asp:ObjectDataSource> <img src="../Images/Global/Star.gif" alt="Required" />
                        <asp:RequiredFieldValidator ID="valRequireForumID" runat="server" ControlToValidate="lstForumID" ErrorMessage="Forum I D is required" ToolTip="Forum I D is required">*</asp:RequiredFieldValidator>

so, basically, that uses the same GetForums object that other parts of the program uses but only actually makes use of the 'ForumID' and 'Title' fields.

[edit]of course, you may wish to break the employess down by department/geography/some other criteria etc depending on the context of the form, otherwise, you'd have gazillions of rows potentially on the dropdown. i'm now officialy 'worried' about your interface :)


jimi

http://www.originaltalent.com
  #67 (permalink)  
Old November 18th, 2007, 05:42 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks. well, in places the list is filtered by certain criteria, in others, it's required to have them all present in the dropdown. this is the case for quite a few dropdowns in the application.

  #68 (permalink)  
Old November 18th, 2007, 06:11 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by forumuser
 thanks. well, in places the list is filtered by certain criteria, in others, it's required to have them all present in the dropdown. this is the case for quite a few dropdowns in the application.
ok - gotcha. re the places where all ahave to be present, wouldn't this be a good candidate for a 'button' next to the current entry which brings up a popup window populated with the full list?? i'm just imagining a scenario where you have thousands of entries. in fact, the popup i'm imagining (ajax probably) would have a-z across the top and default to the letter (and list of names), that matched the current entry. on clicking on a 'letter', a new list would be refreshed that was based on that selection. clicking on a list entry would close the popup and populate the database and refresh the base form with the new value.

that's kinda how i 'see' this kinda thing working across an unknown size of data.

just my 'tuppence' worth - hope it came across as advice, rather than criticism as i was just curious as to how this would work in practice.



jimi

http://www.originaltalent.com
  #69 (permalink)  
Old November 19th, 2007, 04:32 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes, i have an ajax enabled screen [with a 'live search] on an admin screen for employees. the dropdowns occur in various places during the forms i referred to before. i'm wondering how i'd effect filtering using tbh architecture...

  #70 (permalink)  
Old November 19th, 2007, 04:55 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how would i deal with this...?

lots of the forms in the application include the employees dropdown in one guise or another. so, when i use the flixon generator, should i include the employees table in all the relevant providers?

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
THB old Template... it´s time for a new look kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 October 5th, 2007 05:42 PM



All times are GMT -4. The time now is 04:49 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.