. I get an error:
System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetViewStores'. 'strCode' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near simple identifier, line 1, column 38.
public class ForeshareBusinessIntelligenceDomain : LinqToEntitiesDomainService<FG_CoreEntities>
{
public IQueryable<viewStore> GetViewStores(string strCode, string strName, string strGroup, string strType, string strCluster, string strChannel, string strArea, string strDisabled)
{
string strQuery = "select strName from viewStores where ";
if (!strCode.StartsWith("("))
{
strQuery += "strCode = @strCode ";
}
ObjectParameter op = new ObjectParameter("strCode", strCode);
return ObjectContext.CreateQuery<viewStore>(strQuery, op);
}
}
I am trying to filter the results of a SQL View dynamically depending on user selections from drop-down lists. The query will be built depending on the user selection by parsing the selection to the function and then building the T-SQL query as a string and then return the result of CreateQuery().
Thanks.