久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

數據類型 text 和 nvarchar 在等于運算符中不兼容

The data types text and nvarchar are incompatible in the equal to operator(數據類型 text 和 nvarchar 在等于運算符中不兼容)
本文介紹了數據類型 text 和 nvarchar 在等于運算符中不兼容的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

這是我的代碼

ProductController.cs

public ActionResult Details(string id)
{
    product productx = productDB.products.Single(pr => pr.Product1 == id);
    return View(productx);


}

Details.aspx

    <td>
        <%-- : Html.ActionLink("Edit", "Edit", new { id=item.Id }) % --> 
        <%: Html.ActionLink("Details", "Details", new { id = item.Product1 })%>
    </td>

這是我用來從 sql 數據庫中列出一些產品的方法,每個產品都有一個指向詳細信息頁面的鏈接以顯示有關它的更多信息

this is what im using to list some products from a sql database, each product have a link to a Details page to show more informations about it

我試圖只將產品標簽放在該鏈接中,讓它顯示類似www.mysite.comproductsattery(不是ID)

what Im trying is to only put the product label in that link to let it show something like www.mysite.comproductsattery (not the id)

我認為這應該可行,但它會拋出一個數據類型 text 和 nvarchar 在等于運算符中不兼容. 錯誤和(pr => pr.Product1.Equals(id)); 都不起作用

I've imagined this should work, but it throw an The data types text and nvarchar are incompatible in the equal to operator. error and neither (pr => pr.Product1.Equals(id)); works

錯誤很明顯,我問我應該怎么做才能讓它以這種方式工作?

the error is clear and Im asking how should I do to make it work this way ?

謝謝

推薦答案

TEXT 列被視為大對象數據,因此不可索引/可搜索.它們也已棄用.所以,實際上,問題出在您的數據庫中,而不是您的應用程序中.

TEXT columns in SQL Server are considered Large Object data and therefore aren't indexable/searchable. They're also deprecated. So, actually, the problem is in your database, not in your application.

如果將列類型更改為 varchar(max),則可以存儲相同數量的字符數據,但應該不會出現此問題.然后,將您的 Linq 更新為 SQL 實體,您將不再遇到此特定錯誤.

If you change the column type to a varchar(max), you can store the same amount of character data but shouldn't have this problem. Then, update your Linq to SQL entity, and you'll no longer get this particular error.

話雖如此……名為ID的列不應該是TEXT varchar(max),它應該是一個自動遞增的整數 ID 或 GUID (uniqueidentifier),因此您可能需要重新訪問您的數據庫設計.但假設您有充分的理由將 ID 設為任意大小的字符串值,上述更改將允許您對列進行過濾.

Having said that... a column named ID shouldn't be TEXT or varchar(max), it should be an auto-increment integer ID or a GUID (uniqueidentifier), so you might want to revisit your DB design. But assuming you have good reasons for IDs to be string values of arbitrary size, the above change will allow you to filter on the column.

這篇關于數據類型 text 和 nvarchar 在等于運算符中不兼容的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 日韩视频在线观看 | 欧美精品在欧美一区二区 | 国产精品成人一区二区三区夜夜夜 | 亚洲一区二区在线免费观看 | 国产精品精品视频 | 亚洲成人一级 | 日本精品视频 | 日韩精品极品视频在线观看免费 | 亚洲国产中文字幕 | 国产婷婷综合 | 欧美在线a | 青青草一区二区三区 | 欧美极品在线 | 久久久久久久久久一区二区 | 国产精品不卡一区二区三区 | 综合色久 | 日韩视频免费在线 | 亚洲美女天堂网 | 99一级毛片 | 热久久免费视频 | 日韩精品视频在线播放 | 欧美日韩在线综合 | 欧美精品1区2区3区 精品国产欧美一区二区 | 久久一热| 欧美精品第一页 | 国产成人综合在线 | 成人无遮挡毛片免费看 | 国产伦精品一区二区三区四区视频 | 精品一区二区三区中文字幕 | 国产综合久久久久久鬼色 | 欧美久久久网站 | 国产高清免费视频 | 亚洲狠狠爱| 中文字幕乱码视频32 | 成人黄色电影免费 | 91av免费观看 | 国内精品久久久久 | 亚洲欧美在线一区 | 亚洲性网| 久草热视频 | 欧美一区二区三区大片 |