LINQpad 用法汇总

 

 

// C# Expression
//Courses
// .Join (
// CourseSections,
// course => course.CourseId,
// section => section.CourseId,
// (course, section) => course
// )
// .Where (course => (course.Type == 3))

// C# Statement(s)
var courseInfo = from course in Courses
join section in CourseSections
on course.CourseId equals section.CourseId into MyLeftJoin
from result in MyLeftJoin.DefaultIfEmpty()
select course;
var courseType3 = courseInfo.Where(course=>course.Type == 3);
courseType3.Dump();

// C# Program
//void Main()
//{
// var courseInfo =GetCourseInfo();
// courseInfo.Dump();
//}
//
//public class CourseInfo{
// public int CourseId{get;set;}
// public int SectionId{get;set;}
//}
//
//public List<CourseInfo> GetCourseInfo(){
// var courseInfo = (from course in Courses
// from section in CourseSections
// where course.CourseId== section.CourseId
// select new CourseInfo {
// CourseId =course.CourseId,
// SectionId =section.SectionId
// }).ToList();
// return courseInfo;
//}

posted @ 2014-09-22 14:05  dapeng888  阅读(647)  评论(0编辑  收藏  举报