ExectuteScalarQuery

Posts   
 
    
cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 03-Jul-2009 00:32:45   

I just want to get a simple value (string) from an object.

SQL should be...SELECT AppCode FROM App WHERE AppID = 1;

Looking at ExecuteScalarQuery...

How do you do this? Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Jul-2009 05:47:33   

You dont need to ExecuteScalarQuery. The best in this case - as is just one row/entity-, just fetch the entity and extract the value (I will assume you are using Adapter, as you didn't post your TemplateSet):

AppeEntity app = new AppEntity(theId);

using (DataAccessAdapter adapter = new DataAccessAdapter())
{
     adapter.FetchEntity(app);
}

string appCode = app.AppCode;

I see, you use Linq. You also could do this:

using (DataAcessAdapter adapter = new DataAccessAdapter())
{
     LinqMetaData metaData = new LinqMetaData(adapter);

     string result = (from a in metaData.App
                 where a.AppId == theId
                 select a.AppCode).ToString();
}

Hope helpful.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 03-Jul-2009 10:49:48   

Christian, it also might help to search through the docs a bit. I know the docs are big and often boring and it might take more time than anticipated to find what you want, but really, it's there to help you out.

Frans Bouma | Lead developer LLBLGen Pro
cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 03:24:19   

Thanks guys, That actually is what I was doing - but I thought it was bad form. Its working & I'm almost out of the woods on the Data Access. Moving into presentation shortly. Thanks Again