2012-03-23 91 views

回答

1

是的。這是支持的,這是一個快速通過如何做到這一點。

改變你的EF SSDL:

<Function Name="AvgStudentGrade" ReturnType="decimal" Schema="dbo" > 
    <Parameter Name="studentId" Mode="In" Type="int" /> 
</Function> 

添加一個方法存根與相應的屬性:在

var students = from s in context.People 
        where s.EnrollmentDate != null 
        select new 
        { 
         name = s.LastName, 
         avgGrade = AvgStudentGrade(s.PersonID) 
        }; 

更多信息和完整的示例:

[EdmFunction("SchoolModel.Store", "AvgStudentGrade")] 
public static decimal? AvgStudentGrade(int studentId) 
{ 
    throw new NotSupportedException("Direct calls are not supported."); 
} 

使用它
http://msdn.microsoft.com/en-us/library/dd456847(VS.100).aspx

+0

感謝您的回覆。除了.edmx和設計器文件外,我無法看到。沒有可用的SSDL文件。如何找到它?謝謝 – Bill 2012-03-23 21:12:55