Passing object through WCF so that server receives client changes

Posted by cvig on Stack Overflow See other posts from Stack Overflow or by cvig
Published on 2010-05-24T22:17:08Z Indexed on 2010/05/24 22:21 UTC
Read the original article Hit count: 167

Filed under:
|
|

I would like to set up a WCF service so that any changes a client makes to an object I send them are also reflected on the server side. For example, if Assembly A has the following...

namespace AssemblyA
{

    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

    [ServiceContract]
    public interface IServer
    {
        [OperationContract]
        Person GetPerson();
    }

}

And Assembly B references Assembly A...

using AssemblyA;

namespace AssemblyB
{
    class Program
    {
        static void Main(string[] args)
        {
            <snip>
            IServer server = factory.CreateChannel();
            Person person = server.GetPerson();
            person.FirstName = "Kilroy";
            person.LastName = "WuzHere";
        }
    }
}

What is the easiest/best way to make it so that the service's copy of the Person object also reflects the changes that the client makes? Is this even possible?

© Stack Overflow or respective owner

Related posts about c#

Related posts about beginner