开发者

Sharing Linq to SQL entities across RIA services

I am creating very thin DTO's and I'm wondering if there is a way of sharing the Linq-to SQL entities themselves. I've tried. I created a metadata class inside of a partial class and set the key annotations. Then I tried to expose the entities in a query from my RIA service. I get on error though that complains about System.Data.Linq in the generated code. This makes sense, but is there a way to do this without carrying over dependencies on this an other libraries not available in Silverlight?

Note, I'm not using the entity framework because it is way to big for my current project. I'd rather use the thin DTO's than bring in EF for this project.

Edits:

My question is more g开发者_如何学Goenerally this: Can LINQ to SQL entities be used directly as RIA Services DTO's and shared by a service?


Short answer: without taking another approach No.

Long answer:

Not all APIs are supported in the .NET Framework version that is represented by the Silverlight runtime. For a complete list of supporter APIs see here:

http://blogs.msdn.com/b/nickkramer/archive/2010/03/19/silverlight-4-rc-api-listing-in-one-big-text-file.aspx

If you try to use any DLLs which have a dependency on APIs that are not supported then you will run into the problem you are experiencing. You cannot push over the LINQ to SQL classes across the RIA wire in their raw state.

The only way this would work is if your LINQ to SQL layer were generated against POCO classes that were mapped to a DataContext such as with this example: http://www.thinqlinq.com/default/LINQ-to-SQL-support-for-POCO.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜