.net serverside joined table searchbuilder

.net serverside joined table searchbuilder

klymov.inekonklymov.inekon Posts: 37Questions: 11Answers: 0

Hi, I have joined table and want to add searchbuilder options for field, but I've met an error

SELECT  [dSCHAN].[SCHAN_ID] as 'value', [dSCHAN].[SCHAN_NAME] as 'label' 
FROM  [dbo].[dCUSTG] 
LEFT JOIN [dSCHAN] ON [dbo].[dCUSTG].[SCHAN_ID] = [dSCHAN].[SCHAN_ID]  
GROUP BY [dSCHAN].[SCHAN_ID]

my code for searchbuilderoptions

sbOpts = new DataTables.SearchBuilderOptions()
   .Table("dbo.dCUSTG")
   .Value("dSCHAN.SCHAN_ID")
   .Label("dSCHAN.SCHAN_NAME")
   .Render(val => System.Web.HttpUtility.HtmlDecode(val)); // return correct if has diacritical 

main table is dCUSTG, joined table dSCHAN. I have an error

Column 'dSCHAN.SCHAN_NAME' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

If I take it correct it want to add for grouping [dSCHAN].[SCHAN_NAME], but I did't find how.

Remarks for code:
1) why i use main table as reference to table .Table("dbo.dCUSTG"). Because full request has another left join, and when I've tried set joined table like .Table("dbo.dSCHAN") it show an error, cause second left join reference on main table.
full request for searchbuilder options

SELECT  [dSCHAN].[SCHAN_ID] as 'value', [dSCHAN].[SCHAN_NAME] as 'label'
 FROM  [dbo].[dCUSTG] 
LEFT JOIN [dSCHAN] ON [dbo].[dCUSTG].[SCHAN_ID] = [dSCHAN].[SCHAN_ID]  
LEFT JOIN  (SELECT DB_ID, CUSTG_ID, Count(0) as Recs From [BNSE-MAMhh].dbo.dCUST GROUP BY DB_ID, CUSTG_ID ) as cnt
                 ON dbo.dCUSTG.DB_ID = cnt.DB_ID and dbo.dCUSTG.CUSTG_ID = cnt.CUSTG_ID  GROUP BY [dSCHAN].[SCHAN_ID]

2) I've set current configuration, cause code works like viewing tables in a databaseы, whose columns can refer to columns in other tables. Both by value and by label value. Columns can be configured, and I cannot specify for editor exactly what will happen, because I am referring to a dynamic configuration.

Sign In or Register to comment.