コード例 #1
0
        static void PrintJoinAll(List <TopicDTO> topics)
        {
            var users    = userDal.GetAll();
            var comments = commentDal.GetAll();

            var res = from ts in topics
                      join us in users on ts.UsersID equals us.IDUser
                      join cs in comments on ts.CommentID equals cs.ID
                      select new { ID = ts.ID, FullName = us.FullName, Title = ts.Title, Text = ts.Text, Comment = cs.CommentText };

            foreach (var i in res)
            {
                Console.WriteLine($"{i.ID} {i.FullName} \nTitle: {i.Title} \nText: {i.Text}");
            }
        }
コード例 #2
0
        protected List <(long ID, string FullName, string Title, string Text)> GetJoinAll(List <TopicDTO> topics)
        {
            var users    = userDal.GetAll();
            var comments = commentDal.GetAll();

            var res = from ts in topics
                      join us in users on ts.UsersID equals us.IDUser
                      join cs in comments on ts.CommentID equals cs.ID
                      select new { ID = ts.ID, FullName = us.FullName, Title = ts.Title, Text = ts.Text, Comment = cs.CommentText };
            List <(long ID, string FullName, string Title, string Text)> ls = new List <(long ID, string FullName, string Title, string Text)>();

            foreach (var i in res)
            {
                Console.WriteLine($"{i.ID} {i.FullName} \nTitle: {i.Title} \nText: {i.Text}");
                ls.Add((i.ID, i.FullName, i.Title, i.Text));
            }

            return(ls);
        }