Good day. Began to deal with wcf . I started with standard examples - mathematical operations, but slightly complicating the task I ran into a problem, I cannot change the data.

There is an interface

 [ServiceContract] public interface IScoreboard { [OperationContract] int GetCount(); [OperationContract] int AddLine(string line, bool weather); [OperationContract] int DeleteLine(int _id); [OperationContract] string GetLine(int _id); } 

There is a class

 [DataContract] public class ServiceScoreboard : IScoreboard { public Line[] note = new Line[24]; public int _id = 0; public int GetCount() { return _id; } public int AddLine(string line, bool weather) { if (_id < 24) { Line lineToAdd = new Line(line, weather); lineToAdd.SetId(_id); note[_id] = lineToAdd; _id++; return _id; } else return -1; } public string GetLine(int _id) { return note[_id].GetLine(); } } 

the problem was that I could not change the values ​​of the class properties
@petya thanks, helped

    1 answer 1

     [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)] 

    And since now this is the answer, you should write more:

    ServiceBehaviorAttribute specifies when a service wcf object is created

    PerSession - a service is created for each client session.

    PerCall - to call each method (accordingly, the service will not store any state)

    Single - one service for all customers