Last days i tried to build working DO4 provider for interlinq. Now i have working DataObjects.NET provider to be used with InterLINQ framework to transfer linq queries agains DO4 through WCF services. My main goal is to have some "client" library which does NOT reference any of DO4 libs (xtensive.*) and no DO model library, where you define your model entities classes. Just make some lightweight library with Dto class as opposite to real model entity classes, which will be mapped to real entity classes on wcf server side by O2O mapping features in latest DO4. I want this "lightweight library" specially for SL applications to not bring too much references to external libraries (to reduce server->client transfer size). Attached solution contains these projects:
Contains class DataObjectsQueryHandler which implements one important interface from InterLINQ - IQueryHandler and is responsible for all magic about translating linq quries on Dto classes (on client side) into linq queries on Entity classes (on server side) and return back IQueryable list of Dto objects as an result of O2O mapping made on server This library is referenced only on server side, not on client side
Contains class DataContext which is inherited from InterLINQ class InterLinqContext and is responsible for making linq quries on client side. Also contains simple Dto objects which are clones of real entity classes from entity model project, which will be used on client side in linq quries This library is referenced on server side and client side -InterLinq.DataObjects.Test.Model (C# library) Contains entity model classes derived from DO4 base class Entity This library is referenced only on server side, not on client side
Starts wcf service, instanting DataObjectsQueryHandler (IQueryHandler), and important one it creates mapping description of Dto classes and Entity classes. Also populate some test initial data. This application references: InterLinq, InterLinq.DataObjects, Interlinq.DataObjects.Common, InterLinq.DataObjects.Test.Model (also others not important now)
Creates connection to wcf service using DataContext and queries for data using linq queries on Dto objects This application references: InterLinq, Interlinq.DataObjects.Common (also others not important now) Note: sample is not optimized, e.g. cached MethodInfo objects gets by reflection and other things. It was made as try it if DO4 can work with InterLINQ. Will make optimization later, if this sample will be usefull for somebody (or for me). Updated at 10.03.2010 12:49:16I made some "radical" changes within method Get<t> in class DataObjectsQueryHandler according to some comments from Alex Yukanin, to build up better projection on server side. This thread was imported from our support forum. The original discussion may contain more detailed answer. |
I'll check the new version today - have no time to do this right now.