Hi Tuna, by ignoring primary Id, I mean the query includes the primary Id by saying "where Id = @p0" where the value for @p0 is 0. Thus, it will never find anything. I always thought that when querying by criteria, the primary key wouldn't be taken into consideration in the query. By the way, there was a bad copy and paste job when specifying the query in question. The query is looking at the primary key not the "SubTypeID" property.
As far as the Transformers goes, I suppose I don't need to use them. I was simply using them so that I could safely convert my results to strongly typed entities. In other words, I only seemed to get the .List<MyEntity>(); to work when using the Transformers. I'm trying to avoid having to use the non-generic .List(), then run a foreach on the list of results (which would of type object), and add each of them to a list of strongly typed entities. On May 27, 2:43 am, Tuna Toksoz <[email protected]> wrote: > What do you mean by ignoring primary Id? > > also you don';t need to use Transformers, do you? > > Tuna Toksöz > Eternal sunshine of the open source mind. > > http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike > > > > On Wed, May 27, 2009 at 10:40 AM, Action Jackson <[email protected]> wrote: > > > I have a question regarding queries by criteria. I have the following > > entity: > > > public class MyEntity > > { > > public virtual SubType Type { get; private set; } > > public virtual Difficulty DifficultyLevel { get; private set; } > > public virtual Category Category { get; private set; } > > public virtual int Id { get; private set; } > > } > > > When I run the following query: > > > public IEnumerable<MyEntity> Search(SearchCriteria criteria) > > { > > return _baseRepository.Session > > .CreateCriteria(typeof (MyEntity)) > > .Add(Restrictions.Eq("SubType", criteria.SubType)) > > .Add(Restrictions.Eq("DifficultyLevel", criteria.Difficulty)) > > .SetResultTransformer(Transformers.AliasToBean(typeof(MyEntity))) > > .List<MyEntity>(); > > } > > > SELECT > > this_.Id as Id39_0_, > > this_.SubTypeID as SubType2_39_0_, > > this_.DifficultyLevelID as Difficul3_39_0_, > > this_.CategoryID as Category4_39_0_ > > FROM tbMyEntities > > this_ > > WHERE this_.Id = @p0 and this_.DifficultyLevelID = @p1 > > > @p0 is 0 and @p1 is the correct value that I set. However, I was > > under the impression that queries by criteria ignored the primary ID. > > Why is it not ignoring? Thanks for any help.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
