Thanks, fixed in r654. On Wed, Oct 29, 2008 at 2:01 AM, Dominik <[EMAIL PROTECTED]> wrote:
> > done: > http://jira.nhibernate.org/browse/NHLQ-17 > > Cheers, > Dominik > > On Oct 28, 7:48 pm, "Chad Lee" <[EMAIL PROTECTED]> wrote: > > Hi Dominik, > > > > Could you create a JIRA <http://jira.nhibernate.org/> issue for this and > > attach the patch there? > > > > On Tue, Oct 28, 2008 at 6:25 AM, Dominik <[EMAIL PROTECTED]> > wrote: > > > > > Hi, > > > > > I'm currently trying NHibernate.Linq and ran into a problem. > > > I tried to work with a Proxy for my classes and it failed with an > > > 'Don't understand x.Name = "test"' exception. > > > After digging around I think I found the problem. > > > It seams to be in the handling of 'interface' properties within Linq. > > > > > I got a new test working (aka failing) for this issue and added a > > > possible implementation. Although, I'm not 100% sure if I did it > > > correctly (I really just spent one day on NHibernate.Linq and about 2 > > > hours on the solution). > > > > > please find below the patch. I would be nice if someone could have a > > > look at it and, if useful, apply it. > > > > > Cheers, > > > Dominik > > > > > <<Patch starts below this line>> > > > > ------------------------------------------------------------------------- > > > > > Index: src/NHibernate.Linq/src/NHibernate.Linq/Visitors/ > > > BinaryCriterionVisitor.cs > > > =================================================================== > > > --- src/NHibernate.Linq/src/NHibernate.Linq/Visitors/ > > > BinaryCriterionVisitor.cs (revision 651) > > > +++ src/NHibernate.Linq/src/NHibernate.Linq/Visitors/ > > > BinaryCriterionVisitor.cs (working copy) > > > @@ -97,6 +97,13 @@ > > > return expr; > > > } > > > > > + protected override Expression > > > VisitMemberAccess(MemberExpression m) > > > + { > > > + Type = BinaryCriterionType.Property; > > > + Name = m.Member.Name; > > > + return m; > > > + } > > > + > > > public static ICriterion GetBinaryCriteria( > > > ICriteria rootCriteria, > > > ISession session, > > > Index: src/NHibernate.Linq/src/NHibernate.Linq.Tests/Entities/User.cs > > > =================================================================== > > > --- src/NHibernate.Linq/src/NHibernate.Linq.Tests/Entities/User.cs > > > (revision 651) > > > +++ src/NHibernate.Linq/src/NHibernate.Linq.Tests/Entities/User.cs > > > (working copy) > > > @@ -4,8 +4,21 @@ > > > > > namespace NHibernate.Linq.Tests.Entities > > > { > > > - public class User > > > - { > > > + public interface IUser > > > + { > > > + int Id { get; set; } > > > + string Name { get; set; } > > > + int InvalidLoginAttempts { get; set; } > > > + DateTime RegisteredAt { get; set; } > > > + DateTime? LastLoginDate { get; set; } > > > + UserComponent Component { get; set; } > > > + Role Role { get; set; } > > > + EnumStoredAsString Enum1 { get; set; } > > > + EnumStoredAsInt32 Enum2 { get; set; } > > > + } > > > + > > > + public class User : IUser > > > + { > > > public virtual int Id { get; set; } > > > > > public virtual string Name { get; set; } > > > @@ -33,6 +46,10 @@ > > > } > > > } > > > > > + > > > + > > > + > > > + > > > public enum EnumStoredAsString { Unspecified, Small, Medium, > > > Large } > > > > > public enum EnumStoredAsInt32 { Unspecified, High, Low } > > > Index: src/NHibernate.Linq/src/NHibernate.Linq.Tests/Entities/ > > > User.hbm.xml > > > =================================================================== > > > --- src/NHibernate.Linq/src/NHibernate.Linq.Tests/Entities/ > > > User.hbm.xml (revision 651) > > > +++ src/NHibernate.Linq/src/NHibernate.Linq.Tests/Entities/ > > > User.hbm.xml (working copy) > > > @@ -1,6 +1,8 @@ > > > <?xml version="1.0" encoding="utf-8" ?> > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > > namespace="NHibernate.Linq.Tests.Entities" > > > assembly="NHibernate.Linq.Tests"> > > > - <class name="User" table="Users"> > > > + <class name="User" table="Users" > > > + proxy="IUser" > > > + > > > > <id name="Id" column="UserId" type="Int32"> > > > <generator class="native" /> > > > </id> > > > Index: src/NHibernate.Linq/src/NHibernate.Linq.Tests/SelectionTests.cs > > > =================================================================== > > > --- src/NHibernate.Linq/src/NHibernate.Linq.Tests/SelectionTests.cs > > > (revision 651) > > > +++ src/NHibernate.Linq/src/NHibernate.Linq.Tests/SelectionTests.cs > > > (working copy) > > > @@ -138,6 +138,18 @@ > > > } > > > > > [Test] > > > + public void CanSelectWithProxyInterface() > > > + { > > > + var query = from user in session.Linq<IUser>() > > > + where user.Name == "ayende" > > > + select user; > > > + > > > + Assert.AreEqual(1, query.Count()); > > > + Assert.AreEqual("ayende", query.First().Name); > > > + > > > + } > > > + > > > + [Test] > > > public void CanSelectBinaryExpressions() > > > { > > > var query = from user in session.Linq<User>() > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NHibernate Contrib - Development Group" 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.ar/group/nhcdevs?hl=en -~----------~----~----~----~------~----~------~--~---
