标签:nts 加载 framework rem star 技术分享 creat load 通过
1 public class Student 2 { 3 public int ID { get; set; } 4 5 public string LastName { get; set; } 6 7 public string FirstMidName { get; set; } 8 9 public DateTime? EnrollmentDate { get; set; } 10 11 public virtual ICollection<Enrollment> Enrollments { get; set; } 12 }
1 public class Enrollment 2 { 3 public int EnrollmentID { get; set; } 4 5 public int CourseID { get; set; } 6 7 public int StudentID { get; set; } 8 9 public int? Grade { get; set; } 10 11 public virtual Student Student { get; set; } 12 13 public virtual Course Course { get; set; } 14 }
1 public class Course 2 { 3 public int CourseID { get; set; } 4 5 public string Title { get; set; } 6 7 public string Credits { get; set; } 8 9 public virtual ICollection<Enrollment> Enrollments { get; set; } 10 }
1 public class Context:DbContext 2 { 3 public Context() : base("ReadMultipleEntity") 4 { 5 6 } 7 8 public DbSet<Student> Students { get; set; } 9 10 public DbSet<Course> Courses { get; set; } 11 12 public DbSet<Enrollment> Enrollments { get; set; } 13 14 protected override void OnModelCreating(DbModelBuilder modelBuilder) 15 { 16 modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); 17 } 18 19 }
1 SELECT 2 [Project1].[ID] AS [ID], 3 [Project1].[LastName] AS [LastName], 4 [Project1].[FirstMidName] AS [FirstMidName], 5 [Project1].[EnrollmentDate] AS [EnrollmentDate], 6 [Project1].[C1] AS [C1], 7 [Project1].[EnrollmentID] AS [EnrollmentID], 8 [Project1].[CourseID] AS [CourseID], 9 [Project1].[StudentID] AS [StudentID], 10 [Project1].[Grade] AS [Grade] 11 FROM ( SELECT 12 [Extent1].[ID] AS [ID], 13 [Extent1].[LastName] AS [LastName], 14 [Extent1].[FirstMidName] AS [FirstMidName], 15 [Extent1].[EnrollmentDate] AS [EnrollmentDate], 16 [Extent2].[EnrollmentID] AS [EnrollmentID], 17 [Extent2].[CourseID] AS [CourseID], 18 [Extent2].[StudentID] AS [StudentID], 19 [Extent2].[Grade] AS [Grade], 20 CASE WHEN ([Extent2].[EnrollmentID] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1] 21 FROM [dbo].[Student] AS [Extent1] 22 LEFT OUTER JOIN [dbo].[Enrollment] AS [Extent2] ON [Extent1].[ID] = [Extent2].[StudentID] 23 ) AS [Project1] 24 ORDER BY [Project1].[ID] ASC, [Project1].[C1] ASC
1 SELECT 2 [Project1].[ID] AS [ID], 3 [Project1].[LastName] AS [LastName], 4 [Project1].[FirstMidName] AS [FirstMidName], 5 [Project1].[EnrollmentDate] AS [EnrollmentDate], 6 [Project1].[C1] AS [C1], 7 [Project1].[EnrollmentID] AS [EnrollmentID], 8 [Project1].[CourseID] AS [CourseID], 9 [Project1].[StudentID] AS [StudentID], 10 [Project1].[Grade] AS [Grade], 11 [Project1].[CourseID1] AS [CourseID1], 12 [Project1].[Title] AS [Title], 13 [Project1].[Credits] AS [Credits] 14 FROM ( SELECT 15 [Extent1].[ID] AS [ID], 16 [Extent1].[LastName] AS [LastName], 17 [Extent1].[FirstMidName] AS [FirstMidName], 18 [Extent1].[EnrollmentDate] AS [EnrollmentDate], 19 [Join1].[EnrollmentID] AS [EnrollmentID], 20 [Join1].[CourseID1] AS [CourseID], 21 [Join1].[StudentID] AS [StudentID], 22 [Join1].[Grade] AS [Grade], 23 [Join1].[CourseID2] AS [CourseID1], 24 [Join1].[Title] AS [Title], 25 [Join1].[Credits] AS [Credits], 26 CASE WHEN ([Join1].[EnrollmentID] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1] 27 FROM [dbo].[Student] AS [Extent1] 28 LEFT OUTER JOIN (SELECT [Extent2].[EnrollmentID] AS [EnrollmentID], [Extent2].[CourseID] AS [CourseID1], [Extent2].[StudentID] AS [StudentID], [Extent2].[Grade] AS [Grade], [Extent3].[CourseID] AS [CourseID2], [Extent3].[Title] AS [Title], [Extent3].[Credits] AS [Credits] 29 FROM [dbo].[Enrollment] AS [Extent2] 30 INNER JOIN [dbo].[Course] AS [Extent3] ON [Extent2].[CourseID] = [Extent3].[CourseID] ) AS [Join1] ON [Extent1].[ID] = [Join1].[StudentID] 31 ) AS [Project1] 32 ORDER BY [Project1].[ID] ASC, [Project1].[C1] ASC
标签:nts 加载 framework rem star 技术分享 creat load 通过
原文地址:http://www.cnblogs.com/Jason-blogs/p/7400505.html