0

I've been handled a school project to complete, and am currently stuck at a specific point. The goal of the project is to create an OO-system that handles the data in a very specific way - both the server and client have the definition of the model-layer info, but the server has to handle all the data saving into a relational database.

Thus, both the client and server has a controller layer, that are quite different. Currently, only the server-side is written, and it handles relational-to-object mapping and in general, the management of all objects (R2O is solved with Entity Framework). But problem is where the reconstructed objects have to be transmitted to the clients in a way or another.

My question is: what would be the best solution to do so? I cannot change the layout (so clients cannot connect directly to the database server, it is a requirement unfortunately that there is a data providing server, and concurrency management must be solved on that part), but I can't really find an easy way to transfer objects of different classes with relations to each other over a TCP connection.

Again then - what is the solution you'd suggest, or to be more broad, what are my options?

5
  • Take a look at WCF - msdn.microsoft.com/en-us/library/ms731082.aspx Commented Sep 17, 2013 at 16:35
  • You need to translate your objects into some other type of data that can be sent over a network, such a strings. This is called serializing your objects (either through a framework, or manually) and then deserializing them on the other end. Commented Sep 17, 2013 at 16:36
  • What kind of server is it? is it a WCF service? if not I would look into this. Commented Sep 17, 2013 at 16:36
  • Tell your teacher to contact me and I'll explain why teaching distributing objects is a terrible idea. Our industry has been trying to do this with poor results for 20 years. In the meanwhile, I suggest researching the concept of DTOs or (DataTransferObjects) martinfowler.com/eaaCatalog/dataTransferObject.html Commented Sep 17, 2013 at 16:39
  • Actually distributing objects is not the exact task, but the easiest implementation I could come up with (task is, make a server-side service that can distribute data that has been already processed from relational form, and is usable directly in code) Commented Sep 17, 2013 at 16:55

2 Answers 2

1

The easiest way to transfer data over TCP/IP in .net is WCF. There is a nice tutorial on code project: http://www.codeproject.com/Articles/406096/A-beginners-tutorial-for-understanding-Windows

Also you will probably need to keep track of entities' state (I mean when they are sent to client and back). If you are using EF, take a look at self-tracking entities: http://msdn.microsoft.com/en-us/data/jj613924.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

Never looked into WCF before, but seemingly this is the best solution. As there will be multiple different clients (including a web interface written in ASP.NET, possibly with MVC3), I will go with implementing it. Thank you very much!
1

You need to look into serialization of objects.

If an object needs to be transferred from the Server to the Client, you will need to serialize it into Binary or another form; transfer it using TCP connection; and then deserialze it at the client end to rebuild the object.

You can transfer one, or many objects in this manner.

This article at MSDN gives an overview of seralisation - http://msdn.microsoft.com/en-us/library/182eeyhh%28v=vs.100%29.aspx.

And this blog entry provides a basic implementation - http://weblogs.asp.net/stevewellens/archive/2009/07/02/serializing-and-deserializing-objects-to-and-from-xml.aspx.

You will have to tailor this further to your needs; but that is the point of the homework I expect.

1 Comment

Serialization is not an option, I've already played with the idea but there's the problem with the constant need of first manually sending the data type, then the actual information, and if there's a slight change server-side, all clients go crazy. So no, unfortunately it cannot be used in my case, though it is very specific, to begin with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.