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

類型“System.String[]"不支持比較運(yùn)算符

Comparison operators not supported for type #39;System.String[]#39;(類型“System.String[]不支持比較運(yùn)算符)
本文介紹了類型“System.String[]"不支持比較運(yùn)算符的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

為什么是這條線:

var category = _dataContext.Categories.Where<Category>(p => p.Keywords.Split(' ').Contains<string>(context.Request.QueryString["q"])).First();

拋出一個(gè) System.NotSupportedException:

throws an System.NotSupportedException:

類型System.String[]"不支持比較運(yùn)算符

Comparison operators not supported for type 'System.String[]'

我該如何解決?謝謝.

推薦答案

所以您正在數(shù)據(jù)庫(kù)中以空格分隔的列中尋找值(來自查詢字符串)?并且您正在使用 Split 來查詢數(shù)據(jù)庫(kù)中的各個(gè)值?

So you are looking for a value (from the query-string) in a space-delimited column in the database? And you're using Split to query the individual values inside the database?

(只是檢查我的假設(shè)...)

(just checking my assumptions...)

string.Split 不支持這種方式(在列數(shù)據(jù)的數(shù)據(jù)庫(kù)中) - 請(qǐng)參閱此處了解 支持的字符串操作.(注意 string.Split 顯式不被支持).

string.Split is not supported in this way (at the database on column data) - see here for the supported string operations. (note that string.Split is explicitly not supported).

我很懶;當(dāng)我在數(shù)據(jù)庫(kù)中對(duì)數(shù)據(jù)進(jìn)行分隔時(shí)(比較少見),我總是在數(shù)據(jù)的開頭和結(jié)尾添加相同的分隔符;然后我可以搜索:

I'm lazy; when I delimit data in the database (relatively rare), I always add the same delimiter to the start and end of the data; then I can just search for:

string searchFor = DELIMITER + searchValue + DELIMITER;
...
.Where(row => row.Value.Contains(searchFor));

然而;在這種情況下,我希望最實(shí)用的選擇可能是編寫一個(gè) UDF 函數(shù)來搜索分隔的 varchar(正確處理第一個(gè)/最后一個(gè)項(xiàng)目),并在數(shù)據(jù)上下文中公開 UDF - 然后使用:

However; in this case, I expect the most practical option might be to write a UDF function that searches a delimited varchar (correctly handling the first/last item), and expose the UDF on the data-context - then use:

.Where(row => ctx.ContainsValue(row.Value, searchValue)); // ContainsValue is our UDF

或者 - 標(biāo)準(zhǔn)化數(shù)據(jù)...

Or - normalise the data...

.Where(row => row.Values.Any(s=>s.Value == searchValue));

這篇關(guān)于類型“System.String[]"不支持比較運(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 —— 有沒有更高效的語法?)
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)用)
主站蜘蛛池模板: 蜜月aⅴ免费一区二区三区 99re在线视频 | 成人片免费看 | 成人免费一区二区三区视频网站 | 国产乱码精品一区二区三区av | 日韩羞羞 | 99热热99| 国产中文字幕亚洲 | 国产精品免费av | 日韩精品一区二 | 99精品欧美一区二区蜜桃免费 | 欧美成人一级 | 精品九九| 91视频正在播放 | 国产成人精品综合 | 色久影院 | 一区二区三区日本 | 色网在线看| 中文在线а√在线8 | 欧美一区二区激情三区 | 狠狠干美女 | 91精品国产乱码久久久久久久久 | 亚洲一区欧美一区 | 国产精品视频免费播放 | 中文字幕日韩一区 | 99国内精品久久久久久久 | 一区二区在线 | 免费视频久久 | 国产成人精品久久二区二区91 | 91中文| 国产精品一二三区 | 亚洲国产精品一区二区三区 | 操亚洲 | 国产区一区二区三区 | 亚洲欧洲av在线 | 国产黄色精品 | 在线免费小视频 | 国产伦一区二区三区久久 | 特级黄一级播放 | 性网站免费 | 视频一区在线 | av在线一区二区 |