草庐IT

LINQ_ENABLED

全部标签

c# - MongoDB C# 驱动程序 : How do I ensure an index using LINQ expressions on the contents of an array?

如何使用MongoDBC#驱动程序确保对数组内容使用LINQ表达式的索引?我目前有一个大致如下所示的领域对象:publicclassTeam{publicTeam(){Members=newList();}publicMongoDB.Bson.ObjectIdId{get;set;}publicstringDisplayName{get;set;}publicLazyReferenceLeader{get;set;}publicListMembers{get;privateset;}}publicclassLazyReference{publicMongoDB.Bson.ObjectI

c# - 使用 C# 和 linq 查询 mongo 中的嵌套属性

我正在尝试使用linq查询来过滤来自Mongo的结果,但是我使用复杂对象的查询都不起作用:以下工作正常:query.Where(o=>(o.Name=="Joe"))但这给了我错误:query.Where(o=>(o.Address.HouseNumber=="1234"))使用2.1.1版的c#驱动程序,如果我使用旧版驱动程序,我会得到:Unabletodeterminetheserializationinformationfortheexpression:p.Address.HouseNumberatMongoDB.Driver.Linq.Utils.BsonSerializati

c# - 如何使用 Linq 查询 Mongo C# 2.2 驱动程序中的嵌套列表?

如何用Linq做聚合查询。我知道有一个AsQueryable()接口(interface)。但是当我进行聚合时似乎会抛出错误。如果我有一个名为person的集合,它存储这样的数据:{"Name":"Punny","Interests":[1,2]}另一个名为interests的集合存储这样的数据:{"_id":1,"name":"music"},{"_id":2,"name":"read"}我想得到这样的东西:{"Name":"Punny","Interests":["music","read"]}如何使用AsQueryable通过Linqto实现此目的?我试过这个:_context.

c# - 表达式树 mongodb linq 不支持 AsQueryable 方法

我在下面写了mongodb的linq查询并得到异常“表达式树不支持AsQueryable方法:”varresult=fromdataindatabase.GetCollection("CollectionName").AsQueryable()selectnewCollectionName{Property=data.Field.AsQueryable().Skip(1).Take(10)} 最佳答案 尝试像这样删除AsQueryable:varresult=fromdataindatabase.GetCollection("Col

c# - Mongo 过滤器 'in' 与 linq 版本

什么会更有效:使用in过滤器:varfilter=Builders.Filter.In(x=>x._id,IdList);或者,使用linq并传递以下表达式:(x=>IdList.Contains(x))MongoDB驱动程序是否能够以相同的方式分解两者? 最佳答案 好吧,我想这取决于您使用过滤器或linq查询的端点。例如:collection.Find(Builders.Filter.In(x=>x.ID,IdList))collection.Find(x=>IdList.Contains(x.ID))都转化为:db.Employ

mongodb - 不能使用 MongoDB.Driver Include ProjectionDefinition 的 LINQ 表达式重载

我很难尝试使用F#在MongoDB数据库中进行聚合。我构建了这个小示例代码来说明:openSystemopenMongoDB.DriveropenMongoDB.BsontypeMyDocument={Id:BsonObjectIdFoo:stringBar:intBaz:boolQuz:DateTime}[]letmain_=letclient=newMongoClient("mongodb://localhost:27017/faggregate")letdb=client.GetDatabase("faggregate")letcollection=db.GetCollectio

c#to vb.net linq选择

我有这一点的代码:Contacts=model.Contacts?.Select(Create).ToList()??newList()哪个是模型工厂的一部分://////CreatestheAccountentityfromtheviewmodel//////TheAccountviewmodel///AnAccountentitypublicstaticAccountCreate(AccountViewModelmodel){//Ifthemodelisnull,returnnullif(model==null)returnnull;//ReturnourmodelreturnnewAcc

c# - 如何通过Linq查询MongoDB中的BsonExtraElements

我使用mongodb[BsonExtraElements]功能来扩展我的类一些动态数据,但不幸的是我无法通过mongodbC#驱动程序创建查询。这是我的模型类:publicclassMongoProductEntity{publicMongoProductEntity(){AdditionalColumns=newBsonDocument{AllowDuplicateNames=false};}[BsonExtraElements]publicBsonDocumentAdditionalColumns{get;set;}publicstringBrandName{get;set;}}这

c# - 条件聚合器的 MongoDb.Linq 等效查询

我按以下方式使用MongoDb.Linq对我的数据进行分组:groupr1bynew{r1.SupId,r1.SupFullName}intog2selectnew{g2.Key.SupFullName,Volunteers=fromv0ing2wherev0.VolId!=g2.Key.SupIdselectnew{v0.VolFullName,v0.VolPeopleCount}}也就是说,我只希望在Volunteers中那些Id与组key不同的人。我期待驱动程序生成一个条件$push,但它给出了一个简单的:"$push":{"VolFullName":"$VolFullName"

linq - 流畅的 mongo Count() 性能

给定这个包装器:publicMongoCollectionGetQuery()whereTEntity:class{varquery=DataBase.GetCollection(typeof(TEntity).Name+"s");returnquery;}publiclongCount(System.Linq.Expressions.Expression>criteria)whereTEntity:class{returnthis.GetQuery().AsQueryable().Count(criteria);}如果我调用Count(),是否会按照文档中所述在服务器上执行查询her