Sqlfunctions can call SQL Server functions in EF

Source: Internet
Author: User

in EF5 Environment , first add EF environment, add Syste.Data.Entity in reference, add namespace using System.Data.Objects.SqlClient;

Then write a controller test

 1  Publicactionresult Index ()2         { 3             intCount =0; 4             using(Models.testprojectdbentities db =Newmodels.testprojectdbentities ())5             { 6                 varQuery = fromCinchDb. AdmininfoeswhereSqlfunctions.square (1.00) ==c.ordersSelectC;7Count =query.tolist (). Count (); 8             } 9Viewbag.count =Count;Ten             returnView (); One}

is operating normally.

in the EF6 environment , there are entityframework and entityframework.sqlserver in our references, and then we add namespaces using System.Data.Entity.SqlServer;

Notice, and EF5 under the namespace is not the same, this place I also appeared a misunderstanding, when my add is using System.Data.Objects.SqlClient; has been an error,

This error is really strange, I find a lot of reasons on the internet has not been found, the last chance to get this result.

Sqlfunctions can call SQL Server functions in EF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.