Hello I am working on an open source project (http://sherwood.codeplex.com/) where we want to hide the usage of DO from the core to be able to switch out the usage of DO with another storage provider if there should be users of the system that do not want to purchase / use DO. Apart from this, I do also think that it improves the all over design / architecture when we implement it this way. Here is a bit of the structure to show what we think of: Sheerwood.Content.Core contains basically - IClientRepository, IClient, IRecordRepository, IRecord, IMeta Then we have Sherwood.Content.DO which implements ClientRepository, Client, Record etc. in a DO model. Most of the project should not know about Sherwood.Content.DO and only use LINQ directly on the interfaces for querying. Now, the problem is that these interfaces are not known by DO and thus most (all?) of the LINQ stuff does not work. I have seen that there is a MaterializedViewAttribute that maybe could be used if the interface was defined in an assembly knowing DO, but since that is not the case here, it is not usable for me. I tried to find a way to "add this attribute" in runtime by editing the DO model, but didn't find it. I also came across InterLINQ when I looked for a solution to this, and for me it looks like it is possible to "remap" the LINQ query to the real DO objects. I do not have any experience in working with LINQ implementations, and think it will be easier to get some directions / tips from you than trying to figure out this all on my own. Another issue is that e.g. IRecord has a property IClient Client, but the DO implementation has Client Client. To implement IRecord correctly in DO.Record, I need to put in:
A LINQ conversion would also need to understand this mapping and map a query on IRecord.Client to Record.Client. I hope this explanation was understandable and that you are able to provide me with a solution. This thread was imported from our support forum. The original discussion may contain more detailed answer. |
I can list two ways of doing this:
Second way implies you define:
So our query translator maintains mappings for DTOs and anonymous types in queries. Btw, what do you think if we'll offer you a redistributable license for DO4 for this project for the cost of regular licenses you'll need? This could save you a lot of time ;) Please contact me by e-mail, if you like the idea. |