EF中使用資料庫的純量值函式

來源:互聯網
上載者:User

標籤:

參考資料:https://msdn.microsoft.com/zh-cn/library/dd456847(v=vs.110).aspx

     http://stackoverflow.com/questions/12481868/how-to-use-scalar-valued-function-with-linq-to-entity

1、首先修改edmx裡添加的這個<Function>,將IsComposable屬性改為false,去掉ReturnType屬性,然後添加子節點<CommandText>

<Function Name="ToDistance" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">  <CommandText>    SELECT dbo.ToDistance(@Lng1,@Lat1,@Lng2,@Lat2)  </CommandText>  <Parameter Name="Lng1" Type="float" Mode="In" />  <Parameter Name="Lat1" Type="float" Mode="In" />  <Parameter Name="Lng2" Type="float" Mode="In" />  <Parameter Name="Lat2" Type="float" Mode="In" /></Function>

2、雙擊開啟edmx檔案,選擇模型瀏覽器,展開****.store,預存程序/函數,選中心儀的函數,右鍵,匯入,在彈出框中選標量,選參數值,確定。

EF中使用資料庫的純量值函式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.