CodeSmith Community
Your Code. Your Way. Faster!

Component Service tier patch to add const Tags to use in Where parameters

Latest post 12-24-2007 3:13 AM by brianb. 2 replies.
  • 12-19-2007 10:33 PM

    • brianb
    • Not Ranked
    • Joined on 12-17-2007
    • Posts 6
    • Points 120

    Component Service tier patch to add const Tags to use in Where parameters

    We've got a few patches that we would like to see go in to the NetTiers source.

    Here's a simple one to make sure that I've got the procedure right:

     

    Scenario

    ====== 

    We are using the Service tier, and some of our custom methods pass "where clauses" down to the GetPaged method. Using the sample PetStore application as an example, our

    petshopDB.Service.AccountService.CustomMethod()

    calls

    petshopDB.Service.AccountServiceBase.GetPaged(string whereClause, string orderBy, int start, int pageLength, out int totalCount) 

     

    Problem

    ====== 

    If we change our Account database table, by changing the name of a column, the whereClause is no longer valid. We have to search through our code for any text references to the changed column.

     

    Solution

    ======

    We would like tags in the Service objects that we can use to refer to the database columns used in our whereClause. For instance:

    public partial class AccountServiceBase : ServiceBase<Account, AccountKey>
        {
            #region Tag Declarations
            /// <summary>
            /// A tag to use in database queries regarding the Id column
            /// </summary>
            public const System.String Id_TAG = "Id";
            /// <summary>
            /// A tag to use in database queries regarding the FirstName column
            /// </summary>
            public const System.String FirstName_TAG = "FirstName";

    ....

     

    We can use these in our whereClause:

        String where = FirstName_TAG + "=Brian";

        GetPaged(where, "", 0, 10, out totalCount) ;

     

    Then when the database column is renamed, the invalid whereClause will generate a compile error. 

     

    I have attached a patch file against revision 686 of svn. The file adds the tags to ComponentViewServiceBase and ComponentServiceBase. 

    Filed under:
    • Post Points: 35
  • 12-24-2007 2:53 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Component Service tier patch to add const Tags to use in Where parameters

     Brian,

    For each entity you already get a enum which lists the columns i.e. AccountColumns.Id, you can just do a ToString() with this to get the textual value.

    hth

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 12-24-2007 3:13 AM In reply to

    • brianb
    • Not Ranked
    • Joined on 12-17-2007
    • Posts 6
    • Points 120

    Re: Component Service tier patch to add const Tags to use in Where parameters

    thanks very much for you help with that swin. 

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