Custom SQL query

Posts   
 
    
idrees
User
Posts: 19
Joined: 01-Feb-2007
# Posted on: 01-Feb-2007 01:20:28   

Hi there

I am new to this company and they are currently using LLBL Gen Pro ver 1.0.2005.1 Final.

I have just started learning LLBL. Meanwhile, can you help me to understand how to create a custom query especially like the one below: select name, max(year) as year from qualification group by name

Thanks in advance.

Idrees

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Feb-2007 04:27:48   

You will want to use a dynamic list for this. If it is very common then you can use the designer to define a TypedList.

For your example you could use something like


// C#
DataAccessAdapter adapter = new DataAccessAdapter();
ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(EmployeeFields.FirstName, 0, "Name", "Qualification");
fields.DefineField(EmployeeFields.Year, 1, "Year", "Qualification", AggregateFunction.Max);

IGroupByCollection groupByClause = new GroupByCollection();
groupByClause.Add(fields[0]);
DataTable dynamicList = new DataTable();
adapter.FetchTypedList(fields, dynamicList, null, 0, null, true, groupByClause);
idrees
User
Posts: 19
Joined: 01-Feb-2007
# Posted on: 01-Feb-2007 04:34:26   

Thanks bclubb for your reply.

I think you've understood me and that's something similar to what I want. But if you look at the other code in the other message

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8877

the method I need to use this returns an IPredicateExpression. So how do I add the result of this adapter to IPredicateExpression?

Btw, we are using Self Servicing compilation and hence do not have DataAccessAdapter. What is the alternative.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Feb-2007 08:02:48   

If you are using SelfServicing, then check the examples in the LLBLGen Pro manual: "Using the generated code -> SelfServicing -> Using TypedViews, TypedLists and Dynamic lists -> Using dynamic lists"

And if you may pass a filter/ predicate expression to the GetMultiAsDataTable() method, please check its parameters.