public static IList<VKMessage> getLastMessages() { using (VKDataContext context = new VKDataContext(VKDataContext.DBConnectionString)) { IQueryable<VKMessage> query = from c in context.VKMessage select c; return query.ToList(); } }
public static IList<VKUser> getUsersByMessage(VKMessage message) { IList<VKUser> userList = new List<VKUser>(); using (VKDataContext context = new VKDataContext(VKDataContext.DBConnectionString)) { IQueryable<UserMessage> usermessagequery = from c in context.UserMessage where c.VKMessageID == message.VKMessageID select c; IList<UserMessage> usermessageList = usermessagequery.ToList(); foreach (UserMessage um in usermessageList) { IQueryable<VKUser> userquery = from c in context.VKUser where c.VKUserID == um.VKUserID select c; foreach(VKUser user in userquery.ToList()){ userList.Add(user); } } } return userList; }