Question

How to find number of row returned by select query

Hi,

 

I am new to creatio. I want to find number of row returned by select query.I have reffered to this link https://academy.creatio.com/documents/technic-sdk/7-15/retrieving-infor…. In the unable to find how to use rowcount property to find row returned by select query.

 

var UserConnection = Get("UserConnection");

var mangager = (DataValueTypeManager)UserConnection.AppManagerProvider.GetManager("DataValueTypeManager");

 var sel = new Select(UserConnection)

            .Column(Column.Asterisk())

        .From("UsrCustomerRegistration")

        .Where("UsrString3").IsEqual(Column.Parameter(email));

 

Could any body help me with this issue?

 

Regards

Nitin Jain

Like 0

Like

2 comments

For a Select query, you'll either execute it as a DataReader or as a scalar result. For example, to get just the count you could do the following: 

var select = new Select(UserConnection)
    .Column(Func.Count("Id"))
    .From("UsrCustomerRegistration")
    .Where("UsrString3").IsEqual(Column.Parameter(email)) as Select;
 
var count = select.ExecuteScalar<int>();

Otherwise, if you wanted to use the results in some way, you could execute as a DataReader, then loop through the results just like any DataReader:

var select = new Select(UserConnection)
    .Column(Column.Asterisk())
    .From("UsrCustomerRegistration")
    .Where("UsrString3").IsEqual(Column.Parameter(email)) as Select;
 
using (var reader = select.ExecuteReader())
{
    while (reader.Read())
    {
        // etc
    }
}

Hope this helps.

Ryan

Ryan Farley,

Thank you Ryan for your help !!

Show all comments