简体   繁体   中英

C# linq query convert to vb.net

I have some C# LINQ code and would like to convert it to vb.net. Can you help? Dim ProjectsPerUser As New List(Of tbProjekt) var currentUserId = 25;
var prjectId = 10;

ProjectsPerUser = db.tbProjekt.Where(s => s.tbUserProjects
                          .Any(x => x.UserId == currentUserId)).ToList();

In the first case, I tried:

Dim ProjectsPerUser As New List(Of tbProjekt)


    var currentUserId = 25;  
    ProjectsPerUser = db.tbProjekt.Where(Function(s) s.tbUserProjects.Any(Function(x) x.UserId = currentUserId )).ToList()

But, I got this error:

Late binding operations cannot be converted to expression tree

on line s.tbUserProjects.Any .

full code: (tables within context: tbProjekt and tbUserProjects)

Dim dabcon As New production_TextEntitesContext
Dim ProjectsPerUsers As New List(Of tbProjekt)
Dim userSessionId As Integer = 111
ProjectsPerUsers = dabcon.tbProjekt.Where(Function(s) s.tbUserProjects.Any(Function(x) x.UserId = userSessionId)).ToList()

应该只是以下问题:

ProjectsPerUser = db.tbProjekt.Where(Function(s) s.tbUserProjects.Any(Function(x) x.UserId = currentUserId)).ToList()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM