Hey Yufeng,

2010/12/25 yufeng <[email protected]>:
> hi:
>  "session.find<User>;" query all field of table,but sometimes I want to
> query only some field not all,How to implement it?I reference

To do this, you will need to define your own data structure to hold
the results. A Dbo object is always completely fetched. By far the
easiest way to have an ad-hoc data structure for these results is to
use a boost::tuple with as many elements as your SQL select clause
fetches arguments.

E.g. something like this:

typedef boost::tuple<long long, std::string, WDate, std::string,
std::string> BlogInfo;

dbo::collection<BlogInfo> aDBBlogs =
mpWebApp->mpDBSession->query<BlogInfo("SELECT
fuid,ftitle,fdate,freader,frun FROM tblog").where("fshow=1 AND
fshare=1").limit(miPageRows).orderBy("frun DESC,fuid
ASC").offset(offset_page);

Then use boost::tie() to get the individual fields of a single BlogInfo object.

Regards,
koen

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to