Problem in Return Dataset

Posts   
 
    
Posts: 97
Joined: 29-Apr-2009
# Posted on: 07-May-2009 06:23:52   

hi

i am using self servicing.

i have following query :

SELECT intNodeID, txtNodeName, intNodeParentID, CMS_ContentDetails.txtTitle,CMS_ContentDetails.txtDefaultURL FROM CMS_ContentDetails

WHERE flgDeleted=0 ORDER BY intNodeOrder

which return dataset.

so how can i implement in LLBLGen, self servicing , so it will return dataset.

i mean, in .NET the query like this :

dataset ds = SomeQuery

so how can i do with LLBLGen???

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 07-May-2009 07:07:13   

Hi Manoj -

You're actually looking for a DataTable, not a DataSet (since a query always returns a single table).

There are a couple ways to do this:

1.) TypedList

You can create TypedLists within the designer. One of the easiest methods because you can select exactly what fields you'd like and join multiple tables together with point & click.

2.) GetMultiAsDataTable

Probably your best choice. Simple call ContentDetails.GetMultiAsDataTable(). You can then just remove the columns you don't want from the DataTable.

3.) Projection

This is the most difficult method, but probably the most customizable. You can basically create your own projection from an EntityView onto anything.

For all of the above, you will need both a Filter (aka PredicateExpression) and a SortClause. For the filter, you will need to import/include a reference to the YourDataObjects.HelperClasses namespace.

PredicateExpression: Dim myFilter As New PredicateExpression(ContentDetailsFields.flgDeleted = 0)

SortClause - look this up in the Designer's Help menu. LLBLGen Pro's Help section & manual is the best in the business. Almost all answers can be found there.

Hope this helps!

Ryan

Posts: 97
Joined: 29-Apr-2009
# Posted on: 07-May-2009 07:38:14   

rdhatch wrote:

Hi Manoj -

You're actually looking for a DataTable, not a DataSet (since a query always returns a single table).

There are a couple ways to do this:

1.) TypedList

You can create TypedLists within the designer. One of the easiest methods because you can select exactly what fields you'd like and join multiple tables together with point & click.

2.) GetMultiAsDataTable

Probably your best choice. Simple call ContentDetails.GetMultiAsDataTable(). You can then just remove the columns you don't want from the DataTable.

3.) Projection

This is the most difficult method, but probably the most customizable. You can basically create your own projection from an EntityView onto anything.

For all of the above, you will need both a Filter (aka PredicateExpression) and a SortClause. For the filter, you will need to import/include a reference to the YourDataObjects.HelperClasses namespace.

PredicateExpression: Dim myFilter As New PredicateExpression(ContentDetailsFields.flgDeleted = 0)

SortClause - look this up in the Designer's Help menu. LLBLGen Pro's Help section & manual is the best in the business. Almost all answers can be found there.

Hope this helps!

Ryan

Thanks Ryan for such a good reply.

i will see these solutions. well the problem is that i have RAD Control treeview and i am binding that treeview by using dataset. so i need dataset. if u can give me some more solutions, it will very good for me.till i am seeing above ur solutions.

Thanks Again.

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 07-May-2009 07:46:01   

Glad to help.

You can easily create a DataSet to encapsulate your DataTable.

Dim myDataSet as New DataSet
myDataSet.Tables.Add(myDataTable)

Ryan

Posts: 97
Joined: 29-Apr-2009
# Posted on: 07-May-2009 08:45:03   

rdhatch wrote:

Glad to help.

You can easily create a DataSet to encapsulate your DataTable.

Dim myDataSet as New DataSet
myDataSet.Tables.Add(myDataTable)

Ryan

Hi Ryan,

This is i want in dataset. thanks brother.

Posts: 97
Joined: 29-Apr-2009
# Posted on: 07-May-2009 10:57:23   

rdhatch wrote:

Glad to help.

You can easily create a DataSet to encapsulate your DataTable.

Dim myDataSet as New DataSet
myDataSet.Tables.Add(myDataTable)

Ryan

hi when i am using following code, it is giving error

ResultsetFields fields = new ResultsetFields(2); fields.DefineField(CustomersFields.CustomerId,0); fields.DefineField(CustomersFields.CompanyName,0); DataTable results = new DataTable(); TypedListDAO dao = new TypedListDAO(); dao.GetMultiAsDataTable(fields, results, 0, null, null, null, true, null, null, 0, 0);

Error : Object reference not set to an instance of an object.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

public bool GetMultiAsDataTable(IEntityFields fieldsToReturn, DataTable tableToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, bool allowDuplicates, IGroupByCollection groupByClause, ITransaction transactionToUse, int pageNumber, int pageSize)
        {
            return base.PerformGetMultiAsDataTableAction(fieldsToReturn, tableToFill, maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, allowDuplicates, groupByClause, transactionToUse, pageNumber, pageSize);
        }

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 07-May-2009 11:12:26   
    fields.DefineField(CustomersFields.CustomerId,0);
    fields.DefineField(CustomersFields.CompanyName,0);

You are using the same index (0) for both fields.

Should have been:

        fields.DefineField(CustomersFields.CustomerId, 0);
        fields.DefineField(CustomersFields.CompanyName, 1);
Posts: 97
Joined: 29-Apr-2009
# Posted on: 07-May-2009 11:16:14   

Walaa wrote:

    fields.DefineField(CustomersFields.CustomerId,0);
    fields.DefineField(CustomersFields.CompanyName,0);

You are using the same index (0) for both fields.

Should have been:

        fields.DefineField(CustomersFields.CustomerId, 0);
        fields.DefineField(CustomersFields.CompanyName, 1);

Thanks Walaa.

Its working.