What is the best practice when implementing Total (read only) fieds?

Posts   
 
    
Joe_PR
User
Posts: 3
Joined: 02-Dec-2008
# Posted on: 09-Dec-2008 21:34:16   

Greetings,

I have a simple form (Winforms) where I display (and let the user edit) all fields of a row/table (except the PK). I do this using data binding. Several fields are numeric (SQL 2005 money). I need to totalize several fields. My first thought was to create a derived class, add a couple read only properties and monitor the PropertyChanged event. But did a search on the forums and found that read only properties (in my own words) hurts the other read-write properties (two-way binding). Is that true? What is the best way to solve this problem without affecting two way binding? What are the best practices? I’m using 2.6 – Adapter – SQL 2005. Thank you very much!

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 09-Dec-2008 22:46:55   

Hi

Our full text indexing appears to be down - could you point me towards the links you found?

If the read-only properties aren't affecting the read-write properties at all, I can't see that it would be a problem.

Matt

Joe_PR
User
Posts: 3
Joined: 02-Dec-2008
# Posted on: 10-Dec-2008 01:08:54   

Thank you Matt for your prompt response. I’m not sure on what post I read it. But in retrospection I think that the best solution is not a derived class, but a partial class with the new Totalizing properties.

Question: if I have a Entity class with a couple of read-only properties (To totalize fields), does that affects the two way data binding (does the entity gets notified of changes to the other fields on the GUI (winforms)? Also, I have a doubt about partial classes. If I use a partial class to generate a read only property that totalizes fields A, B & C. How can I get notified that that those properties changed. I know that I have to call OnPropertyChanged (if the total changed), should I override this method (in order to get notification of Fields A, B & C changes and recalculate)? Is that the best practice or the correct way to do it? Thank you very much.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Dec-2008 03:58:02   

As far as I know, you have these two options: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=10287&StartAtMessage=0&#57257 And yes, the 2nd. option limits the two-way capabilities.

If you calculate as the 1st. option, you sholdn't trap any OnPropertyChanged event, I think.

David Elizondo | LLBLGen Support Team