Dear all,
When I try to query(/api/data?name=storm,prestl,bcam&tag=78473TAC4,12669VAC2,05946XYZ0).
I am getting (no data) response. I have tested the query with its values against my sql and its able to output 10 records.
var data = db.database_Bd.AsQueryable();
if (query.startDate != null)
{
data = data.Where(c => c.UploadDate >= query.startDate);
}
if (!string.IsNullOrEmpty(query.name))
{
var list = query.name.split(',');
data = data.Where(pr => list.Any(pr2 => pr.Name.Contains(pr2)));
}
if (!string.IsNullOrEmpty(query.tag))
{
var list = query.tag.split(',');
data = data.Where(pr => list.Any(pr2 => pr.TAG.Contains(pr2)));
}
The following updated code:
var filteredData = new List<IQueryable<database_bd>>();
if (!string.IsNullOrEmpty(query.tag))
{
var ids = query.tag.Split(',');
foreach (string i in ids)
{
var list = data.Where(c => c.TAG != null && c.TAG.Contains(i)).AsQueryable();
filteredData.Add(list);
}
}
if (filteredData.Count != 0)
{
data = filteredData.Aggregate(Queryable.Union);
}
I am experiencing an error
(ExceptionMessage":"Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.) when I run a query such as:
api/test?tag = 78473,12669,05946,
45660,02150,12667,4566,3622,38379,
61755,45660,3384,288,23242,81378,
68402,59025,59024,59024,59023,12669,
76111,86359,05946,05946
01448,07387,14889,22545,3136,38137, 49638
Please help. Any advice, would be much appreciated, if possible.