Conversion Linq result to object type in vb.net -


i need vb.net syntax of below answer(given in c#)-

how can convert linq results dto class object without iteration

i have tried converting vb.net @ this link, give compilation errors.

following output above convertor -

public function [get]() list(of user) using db = new mycontext()     return (from u in db.usersorder u.firstnamenew user() { _         key .id = u.pkuser, _         key .username = u.username, _         key .password = u.password, _         key .active = u.active _     }).tolist() end using end function 

well, linq query messed up. , since there's no user class in code tried convert, converter tried use key keyword, used anonymous types.

so correct code should like:

public function [get]() list(of user)     using db = new mycontext()         return (from u in db.users                 order u.firstname                 select new user() {                      .id = u.pkuser,                      .username = u.username,                      .password = u.password,                      .active = u.active                  }).tolist()     end using end function 

assuming following user class:

public class user     public id integer     public username string     public password string     public active boolean end class 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -