How to simulate this code in LLBLGEN?

Posts   
 
    
chungpn
User
Posts: 39
Joined: 23-Mar-2011
# Posted on: 23-Mar-2011 10:46:49   

Hi EveryBody

I'm so begginer with llblGen Pro ... Can AnyOne Help Me to simulate this code in LLBLGEN?

SqlConnection con = new SqlConnection(DataBase.connectionString); SqlCommand cmd = new SqlCommand(); try { con.Open(); cmd.Connection = con; cmd.CommandText = "SELECT top 1 picture FROM emps order by ID desc"; byte[] Img = (byte[])cmd.ExecuteScalar();

        }
        catch
        {

        }
        finally
        {
            con.Close();
        }

where I have emps table mapping to EmpEntity

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 23-Mar-2011 11:17:24   

Use a DynamicList. Pass 1 to the maxItemsToreturn parameter (for the Top), and ake sure you pass a sortExpression for the orderBy.

chungpn
User
Posts: 39
Joined: 23-Mar-2011
# Posted on: 23-Mar-2011 11:29:53   

Thank you for your quickly help!

But as for learing LLBLGEN, I want to know there is any way to achieve this if not use Dynamic List?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 23-Mar-2011 14:23:00   

You can do the same thing by fetching an entityCollection, and using IncludeExcludeList to limit the list of fetched fields to the image field, only.

chungpn
User
Posts: 39
Joined: 23-Mar-2011
# Posted on: 24-Mar-2011 02:01:34   

I can use stored procedure tho do this, too. Thank alot