How to do a full outer join in Linq?

后端 未结 5 1932
花落未央
花落未央 2020-12-02 23:01

I\'ve inherited a database that wasn\'t designed exactly optimally, and I need to manipulate some data. Let me give a more common analogy of the kind of thing I have to do:

5条回答
  •  攒了一身酷
    2020-12-02 23:43

    A start...

     var q = from sc in StudentClass
                join st in StudentTeachers on sc.StudentID equals st.StudentID into g
                from st in g.DefaultIfEmpty()
                select new {StudentID = sc.StudentID, StudentIDParent = st == null ? "(no StudentTeacher)" : st.StudentID...........};
    

    See also http://www.linqpad.net/ for more samples Good tool to play with

提交回复
热议问题