I want to pass the table as parameter for my sqlQuery . I have a lot of tables with the same colums but different values so it would be nice if the costumer could choose the table .
[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;
}
And this is the Error i get back when i excecute it :
<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>