ES version : 2007.1.1210.0
SQL server 2005 / ASP.Net 2.0
Hello, i'm using a dynamic query to populate a collection.
Code is compiling and executing well, but collection is not populated because the DataTable in OnQueryLoaded is empty (rowcount = 0).
The generated SQL Code is ok. I catch it with SQLProfiler and play it in a queryAnalyser, it's ok, it return 3 rows. but in OnQueryLoaded Method, DataTable has 0 row.
I past the code below.
Thanks for your help.
AppCode :
Code:
1 CMSArticleCollection vArticleCollection = new CMSArticleCollection();
2 vArticleCollection.es.Connection.Name = Constantes.ConnexionStringName;
3 CMSArticleQuery vQArticle = new CMSArticleQuery("QArticle");
4 ArticleTagingQuery vQArticleTaging = new ArticleTagingQuery("QArticleTaging");
5 vQArticleTaging.es.Connection.Name = Constantes.ConnexionStringName;
6 if (pTypeArticleId.HasValue)
7 {
8 vQArticle.Where(vQArticle.TypeArticleId.Equal(pTypeArticleId.Value));
9 }
10 if (pSousRubriqueId.HasValue)
11 {
12 vQArticle.Where(vQArticle.SousRubriqueId.Equal(pSousRubriqueId.Value));
13 }
14 if (!string.IsNullOrEmpty(pStatus))
15 {
16 vQArticle.Where(vQArticle.ArticleStatus.Equal(pStatus));
17 }
18 else
19 {
20 vQArticle.Where(vQArticle.ArticleStatus.NotEqual(Constantes.Status.Deleted));
21 }
22 if (pTagIdList != null)
23 {
24 if (pTagIdList.Count > 0)
25 {
26 //Filtre Sur les Tags
27 string[] vStringTagIdList = new string[pTagIdList.Count];
28 for (int i = 0; i < pTagIdList.Count; i++)
29 {
30 vStringTagIdList
= string.Format("{0}", pTagIdList
);
31 }
32 vQArticle.InnerJoin(vQArticleTaging).On(vQArticle.ArticleId == vQArticleTaging.ArticleId).Where(
33 vQArticleTaging.TagId.In(vStringTagIdList));
34 }
35 else
36 {
37
38 //Articles sans Tags
39 vQArticle.LeftJoin(vQArticleTaging).On(vQArticle.ArticleId == vQArticleTaging.ArticleId).Where(
40 vQArticleTaging.TagId.IsNull());
41 }
42 }
43 if (pArticleOrderMin.HasValue)
44 {
45 vQArticle.Where(vQArticle.ArticleOrder.GreaterThanOrEqual(pArticleOrderMin.Value));
46 }
47 if (pArticleOrderMax.HasValue)
48 {
49 vQArticle.Where(vQArticle.ArticleOrder.LessThanOrEqual(pArticleOrderMax.Value));
50 }
51
52 foreach (OrderItem vOrderItem in pOrderItems)
53 {
54 vQArticle.OrderBy(vOrderItem.ColumnName, vOrderItem.Direction);
55 }
56 vArticleCollection.Load(vQArticle);
57 return vArticleCollection;
Generated SQL:
exec sp_executesql N'SELECT * FROM [CMSArticle] QArticle WHERE QArticle.[SousRubriqueId] = @SousRubriqueId1 AND QArticle.[ArticleStatus] = @ArticleStatus2 AND
QArticle.[ArticleOrder] >= @ArticleOrder3 AND QArticle.[ArticleOrder] <= @ArticleOrder4 ORDER BY [ArticleDateManuelle] DESC',N'@SousRubriqueId1
uniqueidentifier,@ArticleStatus2 varchar(9),@ArticleOrder3 int,@ArticleOrder4
int',@SousRubriqueId1='28F51CA5-1B05-4071-B1F2-A4FB0468AEAD',@ArticleStatus2='Published',@ArticleOrder3=0,@ArticleOrder4=0