コード例 #1
0
        public static DBUser GetUser(int Id)
        {
            var filter = new FilterUser()
            {
                Id = Id
            }.ToFilter();
            var user = new DBUser();

            using (ApplicationContext db = new ApplicationContext())
            {
                user = db.Users.Include(x => x.City).Where(filter).FirstOrDefault();
            }
            return(user);
        }
コード例 #2
0
        public static List <DBUser> GetUsers(string name = "")
        {
            var filter = new FilterUser()
            {
                Name = name
            }.ToFilter();
            var users = new List <DBUser>();

            using (ApplicationContext db = new ApplicationContext())
            {
                users = db.Users.Include(x => x.City).Where(filter).ToList();
                foreach (var usr in users)
                {
                    var login = db.Logins.FirstOrDefault(x => x.UserId == usr.Id).Login;
                    usr.Logins.Add(new DBLogin()
                    {
                        Login = login
                    });
                }
            }
            return(users);
        }