C# 将 CouchDB 与 .NET 结合使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1050152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Use CouchDB with .NET
提问by Developer
Can .NET (managed code) read and write to CouchDB?
.NET(托管代码)可以读写 CouchDB 吗?
I would like to build a part of my project that does document management using CouchDB
我想构建我的项目的一部分,使用 CouchDB 进行文档管理
采纳答案by BengtBe
Take a look at the SharpCouchutility class.
看看SharpCouch实用程序类。
It is a simple wrapper class for the CouchDB HTTP API.
它是 CouchDB HTTP API 的简单包装类。
回答by Jon Skeet
Given that you generally communicate with CouchDB over REST and JSON, I'd imagine it wouldn't be too hard to use JSON.NETand the normal WebClient/HttpWebRequest classes to do it. I haven't tried it myself, mind you...
鉴于您通常通过 REST 和 JSON 与 CouchDB 进行通信,我想使用JSON.NET和普通的 WebClient/HttpWebRequest 类来做到这一点并不会太难。我自己没试过,请注意...
回答by ScottS
Yes.
是的。
See herefor instructions on installing CouchDB on windows.
有关在 Windows 上安装 CouchDB 的说明,请参见此处。
Here is a link to the getting started with C#wiki article. There is a link to a .Net wrapper in that article. It would be pretty easy to roll your own as well.
回答by Dokie
I have used JSON.NET in conjunction with the MS REST starter kit's http client class to integrate to CouchDB and it works really well.
我已经将 JSON.NET 与 MS REST 入门工具包的 http 客户端类结合使用,以集成到 CouchDB 中,并且效果非常好。
回答by Dale Ragan
Keep an eye on Ottomanan open-source project written in C#. It is still in heavy development, but I wanted to point it out as an option for projects in the planning stages. I will update this post as it gets closer to completion. You can view the source on github. Read the README to see examples and what is possible with the current version.
关注Ottoman一个用 C# 编写的开源项目。它仍在大力开发中,但我想指出它是规划阶段项目的一个选项。当它接近完成时,我会更新这篇文章。您可以在github上查看源代码。阅读自述文件以查看示例以及当前版本的可能性。
- Unlike SharpCouch, which uses strings heavily, Ottoman uses generics for automatic serialization and desrialization for mapping an object from a JSON string and vice versa. All this without your objects needing to inherit off an interface or base class.
- It uses Json.Net underneath to handle the JSON serialization and deserialization.
- Maps the RESTFul error codes that CouchDB returns into Exceptions.
- Planned Feature: Id generators for generating Id's for the objects being persisted
- Planned Feature: Implicit Offline Optimistic Lockvia Document Revisions, Ottoman will use an Identity Mapto keep track for you and will throw an exception when a conflict occurs.
- Planned Feature: It will be Mono compatible.
- Planned Feature: This is down the road, but I do plan on having LINQ expressions for Map/Reduce functionswhich you express to CouchDB using JavaScript.
- 与大量使用字符串的 SharpCouch 不同,Ottoman 使用泛型进行自动序列化和反序列化,以便从 JSON 字符串映射对象,反之亦然。所有这些都不需要您的对象继承接口或基类。
- 它在底层使用 Json.Net 来处理 JSON 序列化和反序列化。
- 将 CouchDB 返回的 RESTFul 错误代码映射到异常中。
- 计划功能:用于为被持久化的对象生成 Id 的 Id 生成器
- 计划功能:通过文档修订隐式离线乐观锁定,Ottoman 将使用 身份地图为您跟踪,并在发生冲突时抛出异常。
- 计划功能:它将与 Mono 兼容。
- 计划功能:这是在路上,但我确实计划为Map/Reduce 函数使用 LINQ 表达式 ,您可以使用 JavaScript 向 CouchDB 表达这些函数。
It is a fairly new project, but very active. Of course, I'm a bit biased also. ;-)
这是一个相当新的项目,但非常活跃。当然,我也有点偏激。;-)
回答by kolosy
回答by nicknystrom
Its a late answer, but do check out Hammock. It's active and going into production use on several projects soon and is receiving regular updates and fixes. Besides basic object persistence, Hammock gives you:
这是一个迟到的答案,但请查看Hammock。它很活跃,很快就会在几个项目中投入生产使用,并且正在接收定期更新和修复。除了基本的对象持久性,Hammock 还为您提供:
- True POCO. You don't even need an 'id' property; Hammock tracks that internally.
- Robust support for views, including an easy to use fluent API that both generates AND executes views, and support for creating custom map/reduce views.
- Attachments support.
- A generic
Repository<>
class that helps bring your queries/views (i.e. _Design doc) together with your c# application code. Repositories are responsible for maintaining _design docs, and this helps keep CouchDB views from feeling like stored procs. - A full unit test suite. This is not prototype software.
- 真正的POCO。你甚至不需要“id”属性;吊床在内部跟踪。
- 对视图的强大支持,包括一个易于使用的 fluent API,可以生成和执行视图,并支持创建自定义地图/减少视图。
- 附件支持。
- 一个通用
Repository<>
类,有助于将您的查询/视图(即 _Design 文档)与您的 c# 应用程序代码结合在一起。存储库负责维护 _design 文档,这有助于避免 CouchDB 视图感觉像存储的 procs。 - 完整的单元测试套件。这不是原型软件。
回答by Daniel Mohl
Check out Relax http://www.sharplearningcurve.com/wiki/Symbiote-Relax.ashx. Relax is a ".Net API abstraction of CouchDB's (excellent) RESTful API. It includes a repository-based interface for document interaction and a server controller for administrative type tasks."
查看放松http://www.sharplearningcurve.com/wiki/Symbiote-Relax.ashx。Relax 是“CouchDB 的(优秀的)RESTful API 的.Net API 抽象。它包括用于文档交互的基于存储库的接口和用于管理类型任务的服务器控制器。”
回答by Skitsanos
Very easy to use .NET API for CouchDB included into WDK10 that you can grab from http://code.google.com/p/skitsanoswdk/it is very flexible and allows you to deal with your data on objects and pure json level.
WDK10 中包含的 CouchDB 的 .NET API 非常易于使用,您可以从http://code.google.com/p/skitsanoswdk/获取它,它非常灵活,允许您处理对象和纯 json 级别的数据。
回答by JP Hellemons
The options (ordered by latest update):
选项(按最新更新排序):
- Skitsanos Webware Development Kithttp://code.google.com/p/skitsanoswdk/source/browse/trunk/WDK10/WDK.API.CouchDb/latest update sep. 2012
- Relax-net/Hammockhttp://code.google.com/p/relax-net/latest update nov. 2011
- CouchDB.Nethttp://couchdbnet.codeplex.com/latest update dec. 2010
- Ottomanhttps://github.com/sinesignal/ottomanlatest update dec. 2010
- Divanhttps://github.com/foretagsplatsen/Divanlatest update jul 2010
- SharpCouchhttp://code.google.com/p/couchbrowse/source/browse/trunk/SharpCouch/SharpCouch.cslatest update aug. 2008
- Skitsanos Webware 开发工具包http://code.google.com/p/skitsanoswdk/source/browse/trunk/WDK10/WDK.API.CouchDb/最新更新 9 月。2012年
- Relax-net/Hammock http://code.google.com/p/relax-net/11 月最新更新。2011年
- CouchDB.Net http://couchdbnet.codeplex.com/ 12 月最新更新。2010年
- 奥斯曼https://github.com/sinesignal/ottoman 12 月最新更新。2010年
- Divan https://github.com/foretagsplatsen/Divan2010 年 7 月最新更新
- SharpCouch http://code.google.com/p/couchbrowse/source/browse/trunk/SharpCouch/SharpCouch.cs 8 月最新更新。2008年