我有一個從sql表中獲取數據的linq查詢。
在我的數據庫值寫入像這樣的值之後的空格:
「Johny(之後5個空格)」。 當我試圖找到「Johny」 - (沒有空格)查詢不起作用。但是當我搜索「Johny」(在Johny之後 - 5個空間,它沒有在那裏顯示) - 它的作品。
因爲我無法改變基地的內容,所以我沒有這方面的許可。
我怎樣才能讓它工作不帶空格 - 只改變我的查詢?
我的代碼:如何使用空格執行linq搜索
var fidn = (repository.users.Join(repository.usersLG,
post => post.pcod ,
meta => meta.pcod,
(post, meta) => new { Post = post, Meta = meta })
.Where(postAndMeta => postAndMeta.Post.fam_v == "Johny ").ToList())
.Select(x => new Final {
mcod = x.Post.mcod,
pcod = x.Post.pcod,
c_ogrn = x.Post.c_ogrn,
fam_v = x.Post.fam_v,
im_v = x.Post.im_v,
ot_v = x.Post.ot_v,
idGK = x.Meta.idGK });
ASP.NET的網頁C#實體框架
你可以使用'fam_v.StartsWith( 「強尼」)的''而不是'== – Nico
這聽起來像場是固定寬字符字段(例如'CHAR(10)')。如果是這種情況,只需將搜索字詞填充到字段的寬度即可。 –
@heinzbeinz這可能會匹配'JohnyBoy',這可能不正確。 –