Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VB.NET Linq to Entities Query with child objects
- Dim ctx As New AdminCoreEntities
- Dim roles = (From r In ctx.Roles where r.Name.StartsWith("cust") Select r) 'list of System.Linq.IQueryable(Of AdminCoreModel.Role)
- Dim items = From i In ctx.QuickLinks.Include("Roles")
- Where (i.TenantID = "470556ba-3574-4b01-a619-b85e9721b966" AndAlso i.Roles.Contains(roles))
- Select New With {
- i.ID,
- i.Name,
- .Roles = (From r In i.Roles Select New With {.Id = r.ID, .Name = r.Name})
- }
- Dim ctx As New AdminCoreEntities
- Dim items = From i In ctx.QuickLinks ' You don't need Include because you're projecting.
- Where (i.TenantID = "470556ba-3574-4b01-a619-b85e9721b966"
- AndAlso i.Roles.Any(Function(role) role.Name.StartsWith("cust"))
- Select New With {
- i.ID,
- i.Name,
- .Roles = (From r In i.Roles Select New With {.Id = r.ID, .Name = r.Name})
- }
Add Comment
Please, Sign In to add comment