VB.Net Lambda查询
发布时间:2020-12-17 07:15:24 所属栏目:百科 来源:网络整理
导读:我知道我可以改变这样的查询 Dim myList As List(Of Tickets) = (From a In db.myTable Where a.ID = id AndAlso a.IsOnline = True).ToList 到lambda Dim myList as List(of Tickets) = db.Where(Function(x) x.ID = id ANDAlso a.IsOnline = true).ToList
我知道我可以改变这样的查询
Dim myList As List(Of Tickets) = (From a In db.myTable Where a.ID = id AndAlso a.IsOnline = True).ToList 到lambda Dim myList as List(of Tickets) = db.Where(Function(x) x.ID = id ANDAlso a.IsOnline = true).ToList 我如何编写lambda版本并告诉它用结果创建一个新对象?像这样: Dim myList As List(Of Tickets) = (From a In db.myTable Where a.ID = id AndAlso a.IsOnline = True Select New TicketType With { .Id = a.rsID.ToString,.Title = a.rsTitle}).ToList 解决方法
您正在寻找Select()方法:
.Select(Function(x) New TicketType With { ... }) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |