CodeSmith Community
Your Code. Your Way. Faster!

GetAll VS GetPaged VS Find : big confusion !

Latest post 12-04-2007 3:03 PM by Wookai. 3 replies.
  • 11-19-2007 10:29 AM

    • Wookai
    • Not Ranked
    • Joined on 10-01-2007
    • Posts 4
    • Points 80

    GetAll VS GetPaged VS Find : big confusion !

    Hi all !

    First, thanks for this wonderful that is .NetTiers ! It saved my days of work !

    I have a question about the generated select methods and their use in strongly type datasources. I understood that Find is more secure than GetPaged (or is it GetAll) because it uses prepared statements and thus is not vulnerable to SQL injection, but is there any other difference I should be aware of ?

    Basically, I need paging, sorting and filtering. The first being quite common, I'll explain the two other requirements :

    1. Sorting : I need to sort my data on table columns (should be straightforward), as well as on "external" data, ie on the column of another table linked by a foreign key. These properties are deeploaded by the datasource, if this helps...
    2. Filtering : I need to filter my resuls according to the value of a bunch of dropdown lists (ie column X between value 1 and value 2, column Y = value 3, etc.), but this should be done on selecting, and not after selection (ie I dont' want to register onSelected and filter my result)

    Could you please give me pointer on which select method I should use according to my requirements (I'd say Find, because it's secure ?) and how to implement external sorting and filtering ?

    Thanks in advance

    Wookai
    • Post Points: 35
  • 12-01-2007 11:36 PM In reply to

    • Polar
    • Top 100 Contributor
    • Joined on 09-04-2007
    • Posts 51
    • Points 935

    Re: GetAll VS GetPaged VS Find : big confusion !

    As far as I know, the only way to filter the results on the db is to use the GetPaged method of the service layer.  With GetPaged you can specify where and order by clauses as well as paging.  The other way is to use GetAll to return all the records and then filter/sort the list in your app, but there is a lot more overhead since more records are send from the db and sorting/filtering is slower than on the db.

    • Post Points: 5
  • 12-04-2007 1:13 PM In reply to

    • Polar
    • Top 100 Contributor
    • Joined on 09-04-2007
    • Posts 51
    • Points 935

    Re: GetAll VS GetPaged VS Find : big confusion !

    Actually there is also another way, using <Entity>Query and <Entity>Service.Find.

    ProjectQuoteService service = new ProjectQuoteService();

    ProjectQuoteQuery query = new ProjectQuoteQuery(true, true);

    query.AppendEquals(ProjectQuoteColumn.ProjectId, projectID.ToString());

    query.AppendEquals(ProjectQuoteColumn.PricebookId, pricebookID.ToString());

    TList<ProjectQuote> projectQuotes = service.Find(query.GetParameters());

    • Post Points: 35
  • 12-04-2007 3:03 PM In reply to

    • Wookai
    • Not Ranked
    • Joined on 10-01-2007
    • Posts 4
    • Points 80

    Re: GetAll VS GetPaged VS Find : big confusion !

     Hi !

     Thanks for you answers ! I like the second solution, bound on the onSelecting event of my gridview and using the paging informations of the gridview, this should be fine !

    Wookai
    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems