简体   繁体   English

T-sql到asp.net实体框架

[英]T-sql to asp.net Entity framework

Select TOP 5 * 
From Kaloriler 
Where KaloriAdi Like '%cikolata%' COLLATE Latin1_general_CI_AI

What is the equivalent in Entity Framework? 实体框架中的等价物是什么?

.Where(x => x.KaloriAdi.Contains("cikolata")); 

But how can I use it COLLATE Latin1_general_CI_AI ? 但我如何使用它COLLATE Latin1_general_CI_AI

Namespace: System.Data.Objects.SqlClient , public static class SqlFunctions 命名空间: System.Data.Objects.SqlClientpublic static class SqlFunctions

Provide you some logic that allows you to converto linq to entities, but in your case, there is no other way than to convert the linq statement into something like this: 为您提供一些逻辑,允许您将lino转换为实体,但在您的情况下,没有其他方法可以将linq语句转换为如下所示:

var sqlRes = db.Database.SqlQuery<ObjectMappingYourSqlResult>
                                ("Select top 5 * 
                                   from Kaloriler 
                                   Where KaloriAdi Like @MyString 
                                   COLLATE Latin1_general_CI_AI ",
                                  new SqlParameter("MyString ", myValue)
                               ).ToList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM