CodeSmith Community
Your Code. Your Way. Faster!

cust["Name"] allways gives string.Empty problem

Latest post 07-05-2008 6:06 PM by vbandrade. 7 replies.
  • 07-02-2008 4:05 AM

    cust["Name"] allways gives string.Empty problem

     Hello. I have problem with EntityBase["Column_Name"] usage of entities.

    Is there any way to  getting it work ?

    Filed under:
    • Post Points: 35
  • 07-02-2008 4:18 PM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 242
    • Points 6,195

    Re: cust["Name"] allways gives string.Empty problem

    I never used, i´ll check it later tonight.

    Can you give more specific details? Are you trying to access a string field? What happens when it´s a int field?

     

    [s

    • Post Points: 35
  • 07-05-2008 5:42 AM In reply to

    Re: cust["Name"] allways gives string.Empty problem

     I tought that is working like datatable  (object o = table1["ColumnName"]) but it is used to make something else i dont know.

     

    • Post Points: 35
  • 07-05-2008 11:56 AM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 242
    • Points 6,195

    Re: cust["Name"] allways gives string.Empty problem

    Hello there, I check de [ operator and i have no idea of what it does.

    Do you want to get the property value base on it's name?

    • Post Points: 35
  • 07-05-2008 2:48 PM In reply to

    • donig
    • Top 100 Contributor
    • Joined on 02-16-2004
    • Virginia, USA
    • Posts 41
    • Points 1,230

    Re: cust["Name"] allways gives string.Empty problem

    I believe the functionality they are looking for would be something like:

    foreach(string colname in entity.TableColumns) {
           Console.WriteLine("Property: {0}  Value: {1}", colname, entity[colname].ToString());

    The cust["Name"] functionality seems be be broken. The generated code is the same as the Error method right above it.

    However, there is also another subtle problem - if you have setup the UsePascalCasing to anything but "None", then there isn't any way to find the actual string name of the parameter you want to access. There is a TableColumns list of strings of the table columns, but they might not match the property values (Table column CustID might end up as property CustId).

    To correctly implement this functionality, we would need to add another string array to hold the actual Property names, and then correct the indexer to return that Property.

    DoniG

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 60
  • 07-05-2008 5:07 PM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 242
    • Points 6,195

    Re: cust["Name"] allways gives string.Empty problem

    I've implemented this funcitonallity in one of my projecs, I'll commit the changes tomorrow and  you can get that in your project monday.

     

    See ya. 

    • Post Points: 5
  • 07-05-2008 6:00 PM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 242
    • Points 6,195

    Re: cust["Name"] allways gives string.Empty problem

    Hello there, I just take a look at .netTiers code and theres a methdo that might solve your problem:

     

    foreach(string colname in entity.TableColumns) {
           Console.WriteLine("Property: {0}  Value: {1}", colname, EntityUtil.GetPropertyValue(entity, colname).ToString());
    }

    Note that GetProperty is case sensitive, so donig's note  is something to think about.

    • Post Points: 5
  • 07-05-2008 6:06 PM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 242
    • Points 6,195

    Re: cust["Name"] allways gives string.Empty problem

    donig:
    However, there is also another subtle problem - if you have setup the UsePascalCasing to anything but "None", then there isn't any way to find the actual string name of the parameter you want to access. There is a TableColumns list of strings of the table columns, but they might not match the property values (Table column CustID might end up as property CustId).

    To correctly implement this functionality, we would need to add another string array to hold the actual Property names, and then correct the indexer to return that Property.

     

    DoniG we could have a property array and not TableColumns, since it makes a lot more sense to have the properties names as .netTiers is a framework to abstract de database. (;

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