Hi,
If I run the in my database :
SELECT *
FROM
Ads AS a
INNER JOIN AdCategories AS ac
on (ac.Id = a.CategoryId)
INNER JOIN Location AS l
on (l.Id = a.UserLocationId)
WHERE
(l.LevelOrder LIKE '2/3/5/%') AND
(a.Title LIKE '%' OR a.Description LIKE '%') AND
a.InactivatedDate IS NULL AND
a.PublishedDate IS NOT NULL AND
a.EndDate >= '2012-02-04 17:01:37' AND
a.EndDate >= '2011-11-04 16:55:26' AND
ac.LevelOrder Like '7/15/33/36_%'
This will return 2 rows but when running the same command with Entity Framework
context.CreateQuery<Ad>(sqlCommand, parameters.ToArray());
output = ads.ToList();
I get nothing?
This is how the SQL statement looks like :
SELECT VALUE a
FROM
Ads AS a
INNER JOIN AdCategories AS ac
on (ac.Id = a.CategoryId)
INNER JOIN Location AS l
on (l.Id = a.UserLocationId)
WHERE
(l.LevelOrder LIKE @locationLevelOrder0) AND
(a.Title LIKE @searchS OR a.Description LIKE @searchS) AND
a.InactivatedDate IS NULL AND
a.PublishedDate IS NOT NULL AND
a.EndDate >= @CurrentTime AND
a.EndDate >= @fetchAdsTo AND
ac.LevelOrder Like @categoryLevelOrder
The parameters looks like this :
LocationLevelOrder0 = 2/3/5/%searchS = %CurrentTime = {2012-02-04 17:31:34}fetchAdsTo = {2011-11-04 17:31:34}categoryLevelOrder = 7/15/33/36/_%
Why do I not get any results with the Entity Framework while I do in SQL manager? And what does the select value a stand for? If I remove it there will be thrown an exception?