简体   繁体   中英

What is the equivalent T-SQL select query for the attached linq query?

I am facing some trouble writing where condition in the SQL select statement match the above criteria. Any advice?

AllCompany = AllCompany
 .Where(company =>fldSector
 .Contains(company["Sectors"].Replace("|", ","))).ToList();

在此处输入图片说明

There is a REPLACE() function in sql-server and it would probably look like this if you do updating on your table:

UPDATE tableName
SET sectors = REPLACE(sectors,'|',',');

See Fiddle Demo

Or if you want simply to SELECT , you can use PATINDEX() :

SELECT sectors  
FROM tableName
WHERE PATINDEX('%|%',sectors) > 0

See Fiddle Demo with PATINDEX

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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