使用波苏斯坚持天青表的存储时, [英] Using POCOs when persisting to Azure Table Storage

查看:207
本文介绍了使用波苏斯坚持天青表的存储时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用的Azure表的存储在我的ASP.NET 5(MVC 6)应用程序,并添加了 WindowsAzure.Storage 的NuGet包,但我真是失望,当我发现我的所有车型entnty需要从 Microsoft.WindowsAzure.Storage.Table.TableEntity 继承。现在,我想最好的解决办法是有2台实体,创造我的主要领域对象和用于保存表存储实体对象之间的映射。我不想在 WindowsAzure.Storage 包添加到我的所有项目。

I'm planning to use Azure Table Storage in my ASP.NET 5 (MVC 6) app and have added the WindowsAzure.Storage NuGet package, but I got really disappointed when I noticed that all my entnty models need to inherit from Microsoft.WindowsAzure.Storage.Table.TableEntity. Now I'm thinking the best solution is to have 2 sets of entities and create mappings between my main domain objects and the entity objects used to persist to Table Storage. I don't want to add the WindowsAzure.Storage package to all my projects.

的去precated Azure的SDK换网在一个点上得到了波苏斯支持,但我不认为这在当前WindowsAzure.Storage。

The deprecated azure-sdk-for-net got support for POCOs at one point, but I don't see this in the current WindowsAzure.Storage.

什么是最好的做法在这里?

What's the best practice here?

推荐答案

您可以从TableEntity继承了,但这样做,你最终会写一些映射code。在您的code,实际上将与表的存储互动,你可以做使用 DynamicTableEntity 来完全控制系列化从更多的表格数据到对象某种映射。

You can get away from inheriting from TableEntity, but to do so you end up writing some mapping code. In your code that actually will interact with Table Storage you can do some mapping from more raw table data to your object using the DynamicTableEntity to control serialization completely.

有一对夫妇的文章,可以帮助你:

There are a couple of articles that may help you out:

  • Azure EntityAdapter with unsupported table types
  • Using the EntityAdapter for Azure Table Storage
  • Using DTOs/POCOs in Azure Table Storage with a EntityAdapter

如果你看一下第二篇文章则显示code是什么样子的被保存在Azure的表的存储更新特定POCO对象。第三篇文章阐述了通过第一的工作,包括支持的ETag

If you look at the second article it shows what the code looks like for a specific POCO object being saved and updated in Azure Table Storage. The third article expands upon the work of the first to include ETag Support.

这篇关于使用波苏斯坚持天青表的存储时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆