Makes sense - sorry for this - but what if it is a list of numbers?
Requiring something like a

var results = Query.List<int>();

I tried this once before and got a SQL error, it did not seem to like
creating the query with the typeof and then returning results with a
different generic.

On May 26, 2:01 pm, Jon Kruger <[email protected]> wrote:
> Try...
>
> var value = (int) query.UniqueResult();
>
>
>
> On Tue, May 26, 2009 at 1:53 PM, Nigel <[email protected]> wrote:
>
> > No I would like just one field. I only need the one field and figure
> > it is more efficient to return one field but I remember having an
> > error creating critera as typeof(Voucher) and then trying to do a
> > query.List<int>();
>
> > I believe I use a Projection to select the field I want but I am not
> > sure how to do the query.List.
>
> > On May 26, 12:48 pm, Jon Kruger <[email protected]> wrote:
> > > Are you saying that you just want one row back or one integer value?  If
> > you
> > > want just one row, you can do query.UniqueResult<Voucher>().
>
> > > Jon
>
> > > On Tue, May 26, 2009 at 11:40 AM, Nigel <[email protected]>
> > wrote:
>
> > > > I have a table with several fields, I want to supply criteria for a
> > > > couple of the fields but only want one field back. So I create a query
> > > > with a typeof Voucher but in the results I only want to get one int
> > > > field back, rather than the whole table, var results =
> > > > query.List<Voucher>(). How do I do this?
>
> > > > public IEnumerable<Voucher> GetUpdatedVouchers(byte[]
> > > > startingTimestamp, int ItemId)
> > > >        {
> > > >            var session = GetCleanSession();
> > > >            var query = session.CreateCriteria(typeof (Voucher));
>
> > > >            query.AddAndConditions()
> > > >                .Property("DBTimestamp").IsGreaterThanOrEqualTo((byte
> > > > [])startingTimestamp);
> > > >            query.AddAndConditions()
> > > >                .Property("Itemid").Equals((int)ItemId);
>
> > > >            var results = query.List<Voucher>();
>
> > > >            return results;
> > > >        }- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to