有没有mongodb C#驱动程序支持System.Dynamic.DynamicObject在.NET 4? [英] Is there mongodb C# driver support System.Dynamic.DynamicObject in .NET 4?
问题描述
我在使用.NET Razor和mongodb的项目上工作。我想这样做:
@ {
var feeds = DP.Database.GetCollection ).FindAll();
}
< ul>
@foreach(动态Feed中的Feed)
{
< li> @ feed.message - @ feed.from.name< / li>
}
< / ul>但是,当前的mongodb C#驱动程序FindAll()返回不支持动态对象的BsonDocument的集合。任何人都知道.NET 4动态支持的mongodb C#驱动程序?
非常感谢
解决方案 目前,在MongoDB驱动程序中不支持动态。这是因为它是基于.NET 3.5。但是,由于.NET 4.0程序集可以引用.NET 3.5程序集,因此您可以在.NET 4.0中编写IBsonSerializationProvider和IBsonSerializer以支持动态。
我们,10gen,正在看着这样做在未来。我在 https://github.com/craiggwilson/mongo-csharp-driver/tree/上煽动了一些支持动态,如果你想看看。有绝对的错误,但它表明这是可能的。
Im working on a project that use .NET Razor and mongodb. I would like to do something like this:
@{
var feeds = DP.Database.GetCollection("feeds").FindAll();
}
<ul>
@foreach (dynamic feed in feeds)
{
<li>@feed.message - @feed.from.name</li>
}
</ul>
However, the current mongodb C# driver FindAll() return collection of BsonDocument which does not support dynamic object. Anybody know a .NET 4 dynamic supported mongodb C# driver?
Thanks a lot
解决方案 Currently, there is no support for dynamic in the MongoDB driver. This is because it is based on .NET 3.5. However, since a .NET 4.0 assembly can reference a .NET 3.5 assembly, it is possible for you to write a IBsonSerializationProvider and an IBsonSerializer in .NET 4.0 to support dynamics.
We, 10gen, are looking at doing this in the future. I have spiked some support at https://github.com/craiggwilson/mongo-csharp-driver/tree/dynamic if you want to take a look. There are most definitely bugs, but it shows that it is possible.
这篇关于有没有mongodb C#驱动程序支持System.Dynamic.DynamicObject在.NET 4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文