草庐IT

Linq2XSD

全部标签

c# - MongoDB c# 驱动程序 : Case Insensitive Compare using in or contains on a list using linq

我正在使用MongoDBC#驱动程序,我想在集合上执行一个linqwhere子句,将属性的小写版本与我在内存中的列表的小写版本进行比较。像这样;items=items.Where(i=>listToCheck.Contains(i.Property.ToLower()));我也试过...items=items.Where(i=>i.Property.ToLower().In(listToCheck));我认为这实际上是正确的并且应该有效,但可能尚未实现。我收到一条错误消息,指出与ToLower()命令相关的“不受支持的where子句”。据我所知,驱动程序目前无法完成此操作,因为它必须使

Linq子选择数据类型

哈哈哈哈哈,学习linq将是我的死。我有一个大量查询来检索报告的数据。我需要添加一个子查询以将相关数据获取到结果集中。子查询中的数据是数据库中的浮点。我的错误是“无法将'type'System.Linq.iqueryable'转换为'float'”查询是:varresults=fromdindb.Deliveriesjoinjindb.Jobsond.Jobequalsj.Job1joincindb.Customersonj.Customerequalsc.Customer1joinmlindb.Material_Locationsonj.Part_Numberequalsml.Materia

c# - 在 LINQ lambda 表达式中使用字符串变量

我有一个类属性名称作为字符串变量,想在LINQ查询中使用它。下面的例子:publicclassDemo{publicstringprop1{get;set;}publicstringprop2{get;set;}publicstringprop3{get;set;}}我能做到vardata=db.Single(d=>d.prop1=="value");但是不知道运行时的属性是什么,并获取像这样的字符串参数stringpropname="prop2";是否有可能在lambda表达式d=>d.propname=="value"中使用它?我不确定它是否可以并且在逻辑上似乎是不可能的。所以想到

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