Man... do I feel stupid for NOT using Get and using where instead. And also NOT committing it.
Get did the job. Thank you. Em quinta-feira, 6 de dezembro de 2012 12h45min43s UTC-2, PeteA escreveu: > PS - you probably want to make sure that you commit your transaction ;). > In your original code it's not committed, so it'll be rolled-back when it's > disposed of by the using block > > > > *From:* [email protected] <javascript:> [mailto: > [email protected] <javascript:>] *On Behalf Of *Pete Appleton > *Sent:* 06 December 2012 14:42 > *To:* [email protected] <javascript:> > *Subject:* RE: [nhusers] System.NotSupportedException: Boolean > Equals(Int32, Int32) > > > > How about (omitting transaction handling etc) > > > > public TEntity Get<TEntity, TId>(TId id) { > > return session.Get<TEntity>(id); > > } > > > > ?? > > > > *From:* [email protected] <javascript:> > [mailto:[email protected]<javascript:>] > *On Behalf Of *Luiz Angelo Heinzen > *Sent:* 06 December 2012 13:07 > *To:* [email protected] <javascript:> > *Subject:* [nhusers] System.NotSupportedException: Boolean Equals(Int32, > Int32) > > > > Hi... Quick question. Pardon me if is too simplistic. I'm new to all of > this. > > > > On "HqlTreeNode VisitMethodCallExpression(MethodCallExpression expression)" > > > > It's called here: > > public TEntity Get<TEntity, TId>(TId Id) > > where TEntity : Entity<TId> > > where TId : IEquatable<TId> > > { > > try > > { > > TEntity result = default(TEntity); > > using (var tx = session.BeginTransaction()) > > { > > *result = session.Query<TEntity>().Where(e => > e.Id.Equals(Id)).FirstOrDefault();* > > * //result = session.Query<TEntity>().Where(e => e.Id > == Id).FirstOrDefault();* > > * //This does not compile - Operator == cannot be > applied of operands of type TId and TId* > > } > > return result; > > } > > catch (Exception ex) > > { > > throw; > > } > > } > > > > public abstract class Entity<IdType> where IdType : IEquatable<IdType> > > { // } > > > > I want to use generics because my Entities can have different type as Id. > Is there a solution. Or must I have a different "Get" for each type that I > have as id? > > > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/nhusers/-/M7TmhsZqYD8J. > To post to this group, send email to [email protected] <javascript:> > . > To unsubscribe from this group, send email to > [email protected] <javascript:>. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > !DSPAM:1,50c0aecf80901365769727! > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected] <javascript:> > . > To unsubscribe from this group, send email to > [email protected] <javascript:>. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/0xhvpgRIQ28J. 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.
