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.