Serializing Linq
-
Hello, in my app framework we have different .NET services on either the same or different physical machines. The current .NET Remoting may or may not be switched to WCF one day. Regardless of that I did not find a statement on the web if it is possible to serialize a Linq request and get the reply back over the wire. Currently we are using handcrafted abstraction objects for the query part and return DataTables, Scalars etc... any ideas? thanks Florian
-
Hello, in my app framework we have different .NET services on either the same or different physical machines. The current .NET Remoting may or may not be switched to WCF one day. Regardless of that I did not find a statement on the web if it is possible to serialize a Linq request and get the reply back over the wire. Currently we are using handcrafted abstraction objects for the query part and return DataTables, Scalars etc... any ideas? thanks Florian
Out of the box EF4 entity objects do not support serialization. You need to convert your model to POCO objects using the ‘ADO.NET POCO Entity Generator’ or the ‘ADO.NET DbContext Generator’(depending on your EF4 version). This can be done automatically by right-clicking on the model design surface and selecting ‘Add Code Generated Item’. From the dialog, select ‘Online Templates’ and the desired generator. Type a name for your T4 template (your model name). A simple POCO class will be created for each entity. To send and receive the POCO classes over the wire via WCF you will need to add some class files/ class project (CyclicReferencesAware and DataContractResolver) and some supporting attributes to the code generated web services interface classes. Here are some links (walk troughs) that explain the process. http://www.sanderstechnology.com/2010/the-ado-net-entity-framework-poco-objects-and-you/10142/ http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx