开发者

Entity Framework via the middle tier

Ok this one is might not have a straight forward answer but lets see.

I am trying to design a DAL that will sit on the network and serve EF objects to developers who are writing clients that need to use our database.

For example:

The DAL has some EF objects called PERSON and DEPARTMENT.

A developer wants to write a client that开发者_高级运维 can reference the DAL using WCF and has exposed to him a proxy context and the EF objects so he can perform normal looking LINQ queries at design time. At run time this query is passed to the DAL which actually executes it and passed the resultant objects back to the client

        var query = from c in DALReference.PERSON
                    where c.FISTNAME == "FRED"
                    select c;

        foreach ( PERSON p in query)
        {
            lstItems.Items.Add(p.FIRSTNAME);   
        }

Now I've read a load of stuff around about how EF v1 is not mature enough yada yada yada. That's not going to work for me. I need code up a solution for a large project that has to be in by Sept next year at the latest so I can't wait for v2 or .NET 4

I've also read about POCO's and Persistence Ignorance by to be honest its all so fragmented I am struggling to get my head around it.

So anyone want to help out with some easy to understand examples, guides or suggestions on how I can achieve this?

Oh yeah and one final piece of the puzzle. I need to communication to happen over TCP not HTTP.

Thanks!


Have you looked at ADO.NET Data Services or RIA Services? Both do more or less what you want, in slightly different ways. I'd start with one of them unless I had a really pressing need not to.


Your going to have to use RIA Services or something like this: http://code.msdn.microsoft.com/exprserialization to send expression trees over the wire to whatever your data store is.

Edit:

Wanted to add that EF4 works pretty well right now and its certainly better at handling detached entities i.e. objects that go across a wire and become disconnect from your context.

This article may be helpful: http://msdn.microsoft.com/en-us/magazine/ee335715.aspx


You might be interested in using the open source N-Tier Entity Framework which uses Entity Framework on server-side and generates the entire infrastructure for building an n-tier architecture based on WCF including an EF-like API on client-side.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜