我想将表作为我的sqlQuery的参数传递。我有很多具有相同colums但不同值的表,所以如果客户可以选择表格会很好。
[WebGet]
public List<callersW> GetCallersByCallerIdF(string table ,string callerid)
{
testCDREntities1 context = this.CurrentDataSource;
//SqlCommandBuilder cmdBuilder = new SqlCommandBuilder();
// string tbName = cmdBuilder.QuoteIdentifier(table);
List<callersW> result = context.Database.SqlQuery<callersW>("SELECT CallerId,CalledID,Created, " +
" Answered,Destroyed,DisconnectionCode,RTP_Caller_G107MOS,RTP_Caller_LostPackets, " +
" RTP_Caller_MaxRfc3550Jitter,RTP_Caller_MeanRfc3550Jitter,RTP_Called_G107MOS, " +
" RTP_Called_LostPackets,RTP_Called_MaxRfc3550Jitter,RTP_Called_MeanRfc3550Jitter FROM "+ table +" where CallerId = '"+ callerid +"'").ToList();
return result;
}
这是我退出时的错误:
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code/>
<m:message xml:lang="nl-BE">Bad Request - Error in query syntax.</m:message>
</m:error>