Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In our WCF service class we have a property in whose setter block we are setting another property. Please see
the below snippet:

public bool isDirty;
public string title;
       [XmlIgnore]
        public bool IsDirty
        {
            get
            {
                return isDirty;
            }
            set
            {
                isDirty = value;
            }
        }
public string Title
        {
            get { return title; }
            set
            {
                if (value != title)
                {
                    IsDirty = true;
                    title = value;
                }
            }
        }
This is working properly when we have tested it through direct Dll reference. But, when are testing it through service reference object the setter block is not working as expected. I.e. the IsDirty flag is not becoming true.

Please advise.

[edit]Inline code converted to code block - OriginalGriff[/edit]
Posted
Updated 25-Jul-11 21:19pm
v2
Comments
Mark Salsbery 26-Jul-11 15:18pm    
Is the setter even being called? Put a breakpoint in there...is IsDirty getting set?

1 solution

Try changing your property base fields to private:
public bool isDirty;
public string title;
Becomes
private bool isDirty;
private string title;
If this throws up any compilation errors, that is your problem.

It is never a good idea to make the property base field for a property public - it defeats the purpose of having a property in the first place.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900