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

數(shù)據(jù)類型 text 和 nvarchar 在等于運(yùn)算符中不兼容

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

問題描述

這是我的代碼

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 數(shù)據(jù)庫(kù)中列出一些產(chǎn)品的方法,每個(gè)產(chǎn)品都有一個(gè)指向詳細(xì)信息頁(yè)面的鏈接以顯示有關(guān)它的更多信息

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

我試圖只將產(chǎn)品標(biāo)簽放在該鏈接中,讓它顯示類似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)

我認(rèn)為這應(yīng)該可行,但它會(huì)拋出一個(gè)數(shù)據(jù)類型 text 和 nvarchar 在等于運(yùn)算符中不兼容. 錯(cuò)誤和(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

錯(cuò)誤很明顯,我問我應(yīng)該怎么做才能讓它以這種方式工作?

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

謝謝

推薦答案

TEXT 列被視為大對(duì)象數(shù)據(jù),因此不可索引/可搜索.它們也已棄用.所以,實(shí)際上,問題出在您的數(shù)據(jù)庫(kù)中,而不是您的應(yīng)用程序中.

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),則可以存儲(chǔ)相同數(shù)量的字符數(shù)據(jù),但應(yīng)該不會(huì)出現(xiàn)此問題.然后,將您的 Linq 更新為 SQL 實(shí)體,您將不再遇到此特定錯(cuò)誤.

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的列不應(yīng)該是TEXT varchar(max),它應(yīng)該是一個(gè)自動(dòng)遞增的整數(shù) ID 或 GUID (uniqueidentifier),因此您可能需要重新訪問您的數(shù)據(jù)庫(kù)設(shè)計(jì).但假設(shè)您有充分的理由將 ID 設(shè)為任意大小的字符串值,上述更改將允許您對(duì)列進(jìn)行過濾.

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.

這篇關(guān)于數(shù)據(jù)類型 text 和 nvarchar 在等于運(yùn)算符中不兼容的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應(yīng)該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語(yǔ)法?)
How to set null value to int in c#?(如何在c#中將空值設(shè)置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時(shí)如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調(diào)用)
主站蜘蛛池模板: 天堂av中文 | 国产亚洲欧美在线 | 国产成人精品一区二区三区四区 | 成人福利视频 | 久久久久亚洲精品 | 97久久久久久 | 亚洲乱码一区二区三区在线观看 | 黄色一级大片在线免费看产 | 精品一二区 | 在线观看黄色大片 | 欧美激情一区二区三区 | 亚洲精品久久久久久一区二区 | 三级视频在线观看电影 | 日批免费在线观看 | 日韩欧美视频 | 午夜视频在线观看一区二区 | 美人の美乳で授乳プレイ | 亚洲精品视频一区二区三区 | 成人性生交大片免费看中文带字幕 | 在线观看免费国产 | 国产成人精品一区二区三区视频 | 一区二区三区av | 福利精品在线观看 | 日韩中文字幕一区 | 久久综合狠狠综合久久综合88 | 国产精品欧美一区二区 | 久久网一区二区三区 | 视频一区二区中文字幕日韩 | 男女爱爱福利视频 | 精精国产视频 | 国产成人一区二区三区久久久 | 成人av在线播放 | 久久男人| 国产一区二区黑人欧美xxxx | 99精品热视频 | 999在线精品 | 伊人91在线 | 日本三级网站在线观看 | av在线免费观看网址 | 久久综合一区 | 日日骚视频 |