zoukankan      html  css  js  c++  java
  • EntityFramework 学习 一 Table-Valued Function in Entity Framework 5.0

    USE [SchoolDB]
        GO
        /****** Object:  UserDefinedFunction [dbo].[GetCourseListByStudentID]  */  
        SET ANSI_NULLS ON
        GO
        SET QUOTED_IDENTIFIER ON
        GO
        CREATE FUNCTION [dbo].[GetCourseListByStudentID]
        (    
            -- Add the parameters for the function here
            @studentID int
        )
        RETURNS TABLE 
        AS
        RETURN 
        (
            -- Add the SELECT statement with parameter references here
            select c.courseid, c.coursename,c.Location, c.TeacherId
        from student s left outer join studentcourse sc on sc.studentid = s.studentid left outer join course c on c.courseid = sc.courseid
        where s.studentid = @studentID
        )

     

     

     

     

    using (var ctx = new SchoolDBEntities())
            {
        //Execute TVF and filter result
                var courseList = ctx.GetCourseListByStudentID(1).Where(c => c.Location.SpatialEquals(DbGeography.FromText("POINT(-122.360 47.656)"))))
                                .ToList<GetCourseListByStudentID_Result>();
    
                   
                foreach (GetCourseListByStudentID_Result cs in courseList)
                    Console.WriteLine("Course Name: {0}, Course Location: {1}", 
                                cs.CourseName, cs.Location);
        }
  • 相关阅读:
    Nginx 模块:--with-http_sub_status_module
    Nginx http请求&日志
    Nginx 目录和配置语法&DNS配置
    Nginx 全局配置
    Nginx 相关操作1
    Nginx入坑基础篇
    杂谈maven工程实践(3)
    杂谈maven工程类型(2)
    杂谈maven相关概念(1)
    Django
  • 原文地址:https://www.cnblogs.com/lanpingwang/p/6622791.html
Copyright © 2011-2022 走看看