Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从c中加载双引号并在sql中显示_C#_Sql Server - Fatal编程技术网

C# 如何从c中加载双引号并在sql中显示

C# 如何从c中加载双引号并在sql中显示,c#,sql-server,C#,Sql Server,我在c上提供了一个字段,并在sql上运行它,问题是在我发布到sql的字符串上,我有双引号,它与\一起进入sql,我如何解决它 string url = @" '<a href=""/p?geoId='+Geo.GeoId+'"">'+Geo.Name+'</a>'; //note: url can be like this and isn't matter on result //string url = " '<a href=\"/p?geoId='+Geo.Ge

我在c上提供了一个字段,并在sql上运行它,问题是在我发布到sql的字符串上,我有双引号,它与\一起进入sql,我如何解决它

string url = @" '<a href=""/p?geoId='+Geo.GeoId+'"">'+Geo.Name+'</a>';
//note: url can be like this and isn't matter on result
//string url = " '<a href=\"/p?geoId='+Geo.GeoId+'\">'+Geo.Name+'</a>';

string filterExpression=string.Format("SELECT Geo.Count as c,{0} as url from Geo ", url);

IQueryable<GeoDto> geoResult =  _entities.Database.SqlQuery<GeoDto>(filterExpression).AsQueryable();

return geoResult ;
但在结果我看到\,我只寻找双引号结果\

您可以尝试:

string url = " '<a href=\"\"/p?geoId='+Geo.GeoId+'\"\">'+Geo.Name+'</a>' ";
如果没有@escape.

href属性,则可以使用单引号。 你可以试试

string url = "'<a href=''/p?geoId='+Geo.GeoId+'''>'+Geo.Name+'</a>'";

但你为什么要加\。我看没有用here@Tushar:因为href的标记需要双引号,并且在c上不能添加它,如果没有或\这里是结果,它是错误的,因为我现在看到它是双引号: