You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2009-08-02 19:56:08
|
Revision: 4674 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4674&view=rev Author: fabiomaulo Date: 2009-08-02 19:55:57 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Merge r4673 (fix NH-1903) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-08-02 19:49:56 UTC (rev 4673) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-08-02 19:55:57 UTC (rev 4674) @@ -260,14 +260,7 @@ public IQuery SetParameter(int position, object val, IType type) { - if (parameterMetadata.OrdinalParameterCount == 0) - { - throw new ArgumentException("No positional parameters in query: " + QueryString); - } - if (position < 0 || position > parameterMetadata.OrdinalParameterCount - 1) - { - throw new ArgumentException("Positional parameter does not exist: " + position + " in query: " + QueryString); - } + CheckPositionalParameter(position); int size = values.Count; if (position < size) { @@ -305,12 +298,26 @@ public IQuery SetParameter<T>(int position, T val) { - return SetParameter(position, val, GuessType(typeof (T))); + CheckPositionalParameter(position); + + return SetParameter(position, val, parameterMetadata.GetOrdinalParameterExpectedType(position + 1) ?? GuessType(typeof(T))); } + private void CheckPositionalParameter(int position) + { + if (parameterMetadata.OrdinalParameterCount == 0) + { + throw new ArgumentException("No positional parameters in query: " + QueryString); + } + if (position < 0 || position > parameterMetadata.OrdinalParameterCount - 1) + { + throw new ArgumentException("Positional parameter does not exist: " + position + " in query: " + QueryString); + } + } + public IQuery SetParameter<T>(string name, T val) { - return SetParameter(name, val, GuessType(typeof (T))); + return SetParameter(name, val, parameterMetadata.GetNamedParameterExpectedType(name) ?? GuessType(typeof (T))); } public IQuery SetParameter(string name, object val) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs 2009-08-02 19:55:57 UTC (rev 4674) @@ -0,0 +1,34 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1907 +{ + public class Something + { + public virtual string Name { get; set; } + public virtual MyType Relation { get; set; } + } + [TestFixture] + public class Fixture: BugTestCase + { + [Test] + public void CanSetParameterQueryByName() + { + using (ISession s = OpenSession()) + { + var q = s.CreateQuery("from Something s where s.Relation = :aParam"); + Assert.DoesNotThrow(()=>q.SetParameter("aParam", new MyType{ ToPersist = 1})); + } + } + + [Test] + public void CanSetParameterQueryByPosition() + { + using (ISession s = OpenSession()) + { + var q = s.CreateQuery("from Something s where s.Relation = ?"); + q.SetParameter(0, new MyType {ToPersist = 1}); + Assert.DoesNotThrow(() => q.SetParameter(0, new MyType { ToPersist = 1 })); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml 2009-08-02 19:55:57 UTC (rev 4674) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1907"> + + <class name="Something"> + <id type="int"> + <generator class="hilo"/> + </id> + <property name="Name"/> + <property name="Relation" type="NHibernate.Test.NHSpecificTest.NH1907.SimpleCustomType, NHibernate.Test"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs 2009-08-02 19:55:57 UTC (rev 4674) @@ -0,0 +1,115 @@ +using System; +using System.Data; +using NHibernate.SqlTypes; +using NHibernate.UserTypes; + +namespace NHibernate.Test.NHSpecificTest.NH1907 +{ + public class MyType + { + public int ToPersist { get; set; } + + public override bool Equals(object obj) + { + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + var other = (MyType)obj; + return ToPersist == other.ToPersist; + } + + public override int GetHashCode() + { + return ToPersist.GetHashCode(); + } + } + + public class SimpleCustomType : IUserType + { + private static readonly SqlType[] ReturnSqlTypes = { SqlTypeFactory.Int32 }; + + + #region IUserType Members + + public new bool Equals(object x, object y) + { + if (ReferenceEquals(x, y)) + { + return true; + } + if (ReferenceEquals(null, x) || ReferenceEquals(null, y)) + { + return false; + } + + return x.Equals(y); + } + + public int GetHashCode(object x) + { + return (x == null) ? 0 : x.GetHashCode(); + } + + public SqlType[] SqlTypes + { + get { return ReturnSqlTypes; } + } + + public object DeepCopy(object value) + { + return value; + } + + public void NullSafeSet(IDbCommand cmd, object value, int index) + { + if (value == null) + { + ((IDbDataParameter)cmd.Parameters[index]).Value = DBNull.Value; + } + else + { + ((IDbDataParameter)cmd.Parameters[index]).Value = ((MyType)value).ToPersist; + } + } + + public System.Type ReturnedType + { + get { return typeof(Int32); } + } + + public object NullSafeGet(IDataReader rs, string[] names, object owner) + { + int index0 = rs.GetOrdinal(names[0]); + if (rs.IsDBNull(index0)) + { + return null; + } + int value = rs.GetInt32(index0); + return new MyType { ToPersist = value}; + } + + public bool IsMutable + { + get { return false; } + } + + public object Replace(object original, object target, object owner) + { + return original; + } + + public object Assemble(object cached, object owner) + { + return cached; + } + + public object Disassemble(object value) + { + return value; + } + + #endregion + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 19:49:56 UTC (rev 4673) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 19:55:57 UTC (rev 4674) @@ -552,6 +552,8 @@ <Compile Include="NHSpecificTest\NH1877\Person.cs" /> <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> + <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1965,6 +1967,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1868\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-08-02 19:50:04
|
Revision: 4673 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4673&view=rev Author: fabiomaulo Date: 2009-08-02 19:49:56 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Fix NH-1907 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-08-02 16:46:25 UTC (rev 4672) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-08-02 19:49:56 UTC (rev 4673) @@ -260,14 +260,7 @@ public IQuery SetParameter(int position, object val, IType type) { - if (parameterMetadata.OrdinalParameterCount == 0) - { - throw new ArgumentException("No positional parameters in query: " + QueryString); - } - if (position < 0 || position > parameterMetadata.OrdinalParameterCount - 1) - { - throw new ArgumentException("Positional parameter does not exist: " + position + " in query: " + QueryString); - } + CheckPositionalParameter(position); int size = values.Count; if (position < size) { @@ -305,12 +298,26 @@ public IQuery SetParameter<T>(int position, T val) { - return SetParameter(position, val, GuessType(typeof (T))); + CheckPositionalParameter(position); + + return SetParameter(position, val, parameterMetadata.GetOrdinalParameterExpectedType(position + 1) ?? GuessType(typeof(T))); } + private void CheckPositionalParameter(int position) + { + if (parameterMetadata.OrdinalParameterCount == 0) + { + throw new ArgumentException("No positional parameters in query: " + QueryString); + } + if (position < 0 || position > parameterMetadata.OrdinalParameterCount - 1) + { + throw new ArgumentException("Positional parameter does not exist: " + position + " in query: " + QueryString); + } + } + public IQuery SetParameter<T>(string name, T val) { - return SetParameter(name, val, GuessType(typeof (T))); + return SetParameter(name, val, parameterMetadata.GetNamedParameterExpectedType(name) ?? GuessType(typeof (T))); } public IQuery SetParameter(string name, object val) Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Fixture.cs 2009-08-02 19:49:56 UTC (rev 4673) @@ -0,0 +1,34 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1907 +{ + public class Something + { + public virtual string Name { get; set; } + public virtual MyType Relation { get; set; } + } + [TestFixture] + public class Fixture: BugTestCase + { + [Test] + public void CanSetParameterQueryByName() + { + using (ISession s = OpenSession()) + { + var q = s.CreateQuery("from Something s where s.Relation = :aParam"); + Assert.DoesNotThrow(()=>q.SetParameter("aParam", new MyType{ ToPersist = 1})); + } + } + + [Test] + public void CanSetParameterQueryByPosition() + { + using (ISession s = OpenSession()) + { + var q = s.CreateQuery("from Something s where s.Relation = ?"); + q.SetParameter(0, new MyType {ToPersist = 1}); + Assert.DoesNotThrow(() => q.SetParameter(0, new MyType { ToPersist = 1 })); + } + } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/Mappings.hbm.xml 2009-08-02 19:49:56 UTC (rev 4673) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1907"> + + <class name="Something"> + <id type="int"> + <generator class="hilo"/> + </id> + <property name="Name"/> + <property name="Relation" type="NHibernate.Test.NHSpecificTest.NH1907.SimpleCustomType, NHibernate.Test"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs 2009-08-02 19:49:56 UTC (rev 4673) @@ -0,0 +1,115 @@ +using System; +using System.Data; +using NHibernate.SqlTypes; +using NHibernate.UserTypes; + +namespace NHibernate.Test.NHSpecificTest.NH1907 +{ + public class MyType + { + public int ToPersist { get; set; } + + public override bool Equals(object obj) + { + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + var other = (MyType)obj; + return ToPersist == other.ToPersist; + } + + public override int GetHashCode() + { + return ToPersist.GetHashCode(); + } + } + + public class SimpleCustomType : IUserType + { + private static readonly SqlType[] ReturnSqlTypes = { SqlTypeFactory.Int32 }; + + + #region IUserType Members + + public new bool Equals(object x, object y) + { + if (ReferenceEquals(x, y)) + { + return true; + } + if (ReferenceEquals(null, x) || ReferenceEquals(null, y)) + { + return false; + } + + return x.Equals(y); + } + + public int GetHashCode(object x) + { + return (x == null) ? 0 : x.GetHashCode(); + } + + public SqlType[] SqlTypes + { + get { return ReturnSqlTypes; } + } + + public object DeepCopy(object value) + { + return value; + } + + public void NullSafeSet(IDbCommand cmd, object value, int index) + { + if (value == null) + { + ((IDbDataParameter)cmd.Parameters[index]).Value = DBNull.Value; + } + else + { + ((IDbDataParameter)cmd.Parameters[index]).Value = ((MyType)value).ToPersist; + } + } + + public System.Type ReturnedType + { + get { return typeof(Int32); } + } + + public object NullSafeGet(IDataReader rs, string[] names, object owner) + { + int index0 = rs.GetOrdinal(names[0]); + if (rs.IsDBNull(index0)) + { + return null; + } + int value = rs.GetInt32(index0); + return new MyType { ToPersist = value}; + } + + public bool IsMutable + { + get { return false; } + } + + public object Replace(object original, object target, object owner) + { + return original; + } + + public object Assemble(object cached, object owner) + { + return cached; + } + + public object Disassemble(object value) + { + return value; + } + + #endregion + } + +} \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 16:46:25 UTC (rev 4672) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 19:49:56 UTC (rev 4673) @@ -540,6 +540,8 @@ <Compile Include="NHSpecificTest\NH1877\Person.cs" /> <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> + <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> + <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1950,6 +1952,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1868\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-02 16:47:19
|
Revision: 4672 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4672&view=rev Author: davybrion Date: 2009-08-02 16:46:25 +0000 (Sun, 02 Aug 2009) Log Message: ----------- applied patch from Jimmy Bogard for NH-1903 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs Property Changed: ---------------- trunk/nhibernate/src/ Property changes on: trunk/nhibernate/src ___________________________________________________________________ Modified: svn:mergeinfo - /branches/2.1.x/nhibernate/src:4659 + /branches/2.1.x/nhibernate/src:4659,4671 Modified: trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs 2009-08-02 16:26:52 UTC (rev 4671) +++ trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs 2009-08-02 16:46:25 UTC (rev 4672) @@ -16,13 +16,13 @@ /// <typeparam name="TKey">The type of the keys in the IDictionary.</typeparam> /// <typeparam name="TValue">The type of the elements in the IDictionary.</typeparam> [Serializable] - [DebuggerTypeProxy(typeof (DictionaryProxy<,>))] + [DebuggerTypeProxy(typeof(DictionaryProxy<,>))] public class PersistentGenericMap<TKey, TValue> : PersistentMap, IDictionary<TKey, TValue> { // TODO NH: find a way to writeonce (no duplicated code from PersistentMap) protected IDictionary<TKey, TValue> gmap; - public PersistentGenericMap() {} - public PersistentGenericMap(ISessionImplementor session) : base(session) {} + public PersistentGenericMap() { } + public PersistentGenericMap(ISessionImplementor session) : base(session) { } public PersistentGenericMap(ISessionImplementor session, IDictionary<TKey, TValue> map) : base(session, map as IDictionary) @@ -37,15 +37,15 @@ foreach (KeyValuePair<TKey, TValue> e in gmap) { object copy = persister.ElementType.DeepCopy(e.Value, entityMode, persister.Factory); - clonedMap[e.Key] = (TValue) copy; + clonedMap[e.Key] = (TValue)copy; } return clonedMap; } public override void BeforeInitialize(ICollectionPersister persister, int anticipatedSize) { - gmap = (IDictionary<TKey, TValue>) persister.CollectionType.Instantiate(anticipatedSize); - map = (IDictionary) gmap; + gmap = (IDictionary<TKey, TValue>)persister.CollectionType.Instantiate(anticipatedSize); + map = (IDictionary)gmap; } public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) @@ -156,7 +156,7 @@ } else { - value = (TValue) result; + value = (TValue)result; return true; } } @@ -166,7 +166,7 @@ get { object result = ReadElementByIndex(key); - return result == Unknown ? gmap[key] : (TValue) result; + return result == Unknown ? gmap[key] : (TValue)result; } set { @@ -234,7 +234,7 @@ { if (exists.Value) { - TValue x = ((IDictionary<TKey, TValue>) this)[item.Key]; + TValue x = ((IDictionary<TKey, TValue>)this)[item.Key]; TValue y = item.Value; return EqualityComparer<TValue>.Default.Equals(x, y); } @@ -269,7 +269,7 @@ bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item) { - if (((ICollection<KeyValuePair<TKey, TValue>>) this).Contains(item)) + if (((ICollection<KeyValuePair<TKey, TValue>>)this).Contains(item)) { Remove(item.Key); return true; @@ -291,5 +291,15 @@ } #endregion + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + Read(); + return gmap.GetEnumerator(); + } + + #endregion } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs 2009-08-02 16:26:52 UTC (rev 4671) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs 2009-08-02 16:46:25 UTC (rev 4672) @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Text; using NHibernate.Engine; @@ -78,6 +79,51 @@ } } + [Test] + public void SimpleTypes() + { + A a = new A(); + a.Name = "first generic type"; + a.Items = new Dictionary<string, B>(); + B firstB = new B(); + firstB.Name = "first b"; + B secondB = new B(); + secondB.Name = "second b"; + B thirdB = new B(); + thirdB.Name = "third b"; + + a.Items.Add("first", firstB); + a.Items.Add("second", secondB); + a.Items.Add("third", thirdB); + + using (ISession s = OpenSession()) + { + s.SaveOrUpdate(a); + s.Flush(); + } + + using (ISession s = OpenSession()) + { + a = s.Load<A>(a.Id); + IDictionary<string, B> genericDict = a.Items; + IEnumerable<KeyValuePair<string, B>> genericEnum = a.Items; + IEnumerable nonGenericEnum = a.Items; + + foreach (var enumerable in genericDict) + { + Assert.That(enumerable, Is.InstanceOf<KeyValuePair<string, B>>()); + } + foreach (var enumerable in genericEnum) + { + Assert.That(enumerable, Is.InstanceOf<KeyValuePair<string, B>>()); + } + foreach (var enumerable in nonGenericEnum) + { + Assert.That(enumerable, Is.InstanceOf<KeyValuePair<string, B>>()); + } + } + } + // NH-669 [Test] public void UpdatesToSimpleMap() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-02 16:27:14
|
Revision: 4671 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4671&view=rev Author: davybrion Date: 2009-08-02 16:26:52 +0000 (Sun, 02 Aug 2009) Log Message: ----------- applied patch from Jimmy Bogard for NH-1903 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs branches/2.1.x/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs 2009-07-30 16:10:11 UTC (rev 4670) +++ branches/2.1.x/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs 2009-08-02 16:26:52 UTC (rev 4671) @@ -16,13 +16,13 @@ /// <typeparam name="TKey">The type of the keys in the IDictionary.</typeparam> /// <typeparam name="TValue">The type of the elements in the IDictionary.</typeparam> [Serializable] - [DebuggerTypeProxy(typeof (DictionaryProxy<,>))] + [DebuggerTypeProxy(typeof(DictionaryProxy<,>))] public class PersistentGenericMap<TKey, TValue> : PersistentMap, IDictionary<TKey, TValue> { // TODO NH: find a way to writeonce (no duplicated code from PersistentMap) protected IDictionary<TKey, TValue> gmap; - public PersistentGenericMap() {} - public PersistentGenericMap(ISessionImplementor session) : base(session) {} + public PersistentGenericMap() { } + public PersistentGenericMap(ISessionImplementor session) : base(session) { } public PersistentGenericMap(ISessionImplementor session, IDictionary<TKey, TValue> map) : base(session, map as IDictionary) @@ -37,15 +37,15 @@ foreach (KeyValuePair<TKey, TValue> e in gmap) { object copy = persister.ElementType.DeepCopy(e.Value, entityMode, persister.Factory); - clonedMap[e.Key] = (TValue) copy; + clonedMap[e.Key] = (TValue)copy; } return clonedMap; } public override void BeforeInitialize(ICollectionPersister persister, int anticipatedSize) { - gmap = (IDictionary<TKey, TValue>) persister.CollectionType.Instantiate(anticipatedSize); - map = (IDictionary) gmap; + gmap = (IDictionary<TKey, TValue>)persister.CollectionType.Instantiate(anticipatedSize); + map = (IDictionary)gmap; } public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) @@ -156,7 +156,7 @@ } else { - value = (TValue) result; + value = (TValue)result; return true; } } @@ -166,7 +166,7 @@ get { object result = ReadElementByIndex(key); - return result == Unknown ? gmap[key] : (TValue) result; + return result == Unknown ? gmap[key] : (TValue)result; } set { @@ -234,7 +234,7 @@ { if (exists.Value) { - TValue x = ((IDictionary<TKey, TValue>) this)[item.Key]; + TValue x = ((IDictionary<TKey, TValue>)this)[item.Key]; TValue y = item.Value; return EqualityComparer<TValue>.Default.Equals(x, y); } @@ -269,7 +269,7 @@ bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item) { - if (((ICollection<KeyValuePair<TKey, TValue>>) this).Contains(item)) + if (((ICollection<KeyValuePair<TKey, TValue>>)this).Contains(item)) { Remove(item.Key); return true; @@ -291,5 +291,15 @@ } #endregion + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + Read(); + return gmap.GetEnumerator(); + } + + #endregion } } \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs 2009-07-30 16:10:11 UTC (rev 4670) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs 2009-08-02 16:26:52 UTC (rev 4671) @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Text; using NHibernate.Engine; @@ -78,6 +79,51 @@ } } + [Test] + public void SimpleTypes() + { + A a = new A(); + a.Name = "first generic type"; + a.Items = new Dictionary<string, B>(); + B firstB = new B(); + firstB.Name = "first b"; + B secondB = new B(); + secondB.Name = "second b"; + B thirdB = new B(); + thirdB.Name = "third b"; + + a.Items.Add("first", firstB); + a.Items.Add("second", secondB); + a.Items.Add("third", thirdB); + + using (ISession s = OpenSession()) + { + s.SaveOrUpdate(a); + s.Flush(); + } + + using (ISession s = OpenSession()) + { + a = s.Load<A>(a.Id); + IDictionary<string, B> genericDict = a.Items; + IEnumerable<KeyValuePair<string, B>> genericEnum = a.Items; + IEnumerable nonGenericEnum = a.Items; + + foreach (var enumerable in genericDict) + { + Assert.That(enumerable, Is.InstanceOf<KeyValuePair<string, B>>()); + } + foreach (var enumerable in genericEnum) + { + Assert.That(enumerable, Is.InstanceOf<KeyValuePair<string, B>>()); + } + foreach (var enumerable in nonGenericEnum) + { + Assert.That(enumerable, Is.InstanceOf<KeyValuePair<string, B>>()); + } + } + } + // NH-669 [Test] public void UpdatesToSimpleMap() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-30 16:10:20
|
Revision: 4670 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4670&view=rev Author: ricbrown Date: 2009-07-30 16:10:11 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Added IQueryOver.Fetch(...) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Criterion/QueryOverFetchBuilder.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-30 09:56:14 UTC (rev 4669) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-30 16:10:11 UTC (rev 4670) @@ -123,6 +123,11 @@ return this; } + public QueryOverFetchBuilder<T> Fetch(Expression<Func<T, object>> path) + { + return new QueryOverFetchBuilder<T>(this, path); + } + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, @@ -306,6 +311,9 @@ IQueryOver<T> IQueryOver<T>.CacheRegion(string cacheRegion) { return CacheRegion(cacheRegion); } + IQueryOverFetchBuilder<T> IQueryOver<T>.Fetch(Expression<Func<T, object>> path) + { return new IQueryOverFetchBuilder<T>(this, path); } + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) { return JoinQueryOver(path); } Added: trunk/nhibernate/src/NHibernate/Criterion/QueryOverFetchBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOverFetchBuilder.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOverFetchBuilder.cs 2009-07-30 16:10:11 UTC (rev 4670) @@ -0,0 +1,69 @@ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +using NHibernate.Impl; +using NHibernate.SqlCommand; + +namespace NHibernate.Criterion +{ + + public class QueryOverFetchBuilder<T> : QueryOverFetchBuilderBase<QueryOver<T>, T> + { + + public QueryOverFetchBuilder(QueryOver<T> root, Expression<Func<T, object>> path) + : base(root, path) { } + + } + + public class IQueryOverFetchBuilder<T> : QueryOverFetchBuilderBase<IQueryOver<T>, T> + { + + public IQueryOverFetchBuilder(IQueryOver<T> root, Expression<Func<T, object>> path) + : base(root, path) { } + + } + + public class QueryOverFetchBuilderBase<R, T> where R : IQueryOver<T> + { + + protected R root; + protected string path; + + protected QueryOverFetchBuilderBase(R root, Expression<Func<T, object>> path) + { + this.root = root; + this.path = ExpressionProcessor.FindMemberExpression(path.Body); + } + + public R Eager + { + get + { + this.root.UnderlyingCriteria.SetFetchMode(path, FetchMode.Eager); + return this.root; + } + } + + public R Lazy + { + get + { + this.root.UnderlyingCriteria.SetFetchMode(path, FetchMode.Lazy); + return this.root; + } + } + + public R Default + { + get + { + this.root.UnderlyingCriteria.SetFetchMode(path, FetchMode.Default); + return this.root; + } + } + + } + +} Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-30 09:56:14 UTC (rev 4669) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-30 16:10:11 UTC (rev 4670) @@ -122,6 +122,14 @@ IQueryOver<T> CacheRegion(string cacheRegion); /// <summary> + /// Specify an association fetching strategy. Currently, only + /// one-to-many and one-to-one associations are supported. + /// </summary> + /// <param name="path">A lambda expression path (e.g., ChildList[0].Granchildren[0].Pets).</param> + /// <returns></returns> + IQueryOverFetchBuilder<T> Fetch(Expression<Func<T, object>> path); + + /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-30 09:56:14 UTC (rev 4669) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-30 16:10:11 UTC (rev 4670) @@ -491,6 +491,7 @@ <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> <Compile Include="Criterion\GroupedProjection.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> + <Compile Include="Criterion\QueryOverFetchBuilder.cs" /> <Compile Include="Criterion\QueryOverJoinBuilder.cs" /> <Compile Include="Criterion\QueryOverOrderBuilder.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-30 09:56:14 UTC (rev 4669) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-30 16:10:11 UTC (rev 4670) @@ -315,6 +315,22 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Fetch() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .SetFetchMode("PersonList", FetchMode.Eager) + .SetFetchMode("PersonList.PersonList", FetchMode.Lazy); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Fetch(p => p.PersonList).Eager + .Fetch(p => p.PersonList[0].PersonList).Lazy; + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-30 09:56:28
|
Revision: 4669 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4669&view=rev Author: ricbrown Date: 2009-07-30 09:56:14 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Moved IQueryOver.OrderBy to more fluent syntax. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Criterion/QueryOverOrderBuilder.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-29 18:46:44 UTC (rev 4668) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-30 09:56:14 UTC (rev 4669) @@ -73,51 +73,51 @@ return this; } - public QueryOver<T> OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + public QueryOverOrderBuilder<T> OrderBy(Expression<Func<T, object>> path) { - return AddOrder(path, orderDelegate); + return new QueryOverOrderBuilder<T>(this, path); } - public QueryOver<T> OrderBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) + public QueryOverOrderBuilder<T> OrderBy(Expression<Func<object>> path) { - return AddOrder(path, orderDelegate); + return new QueryOverOrderBuilder<T>(this, path); } - public QueryOver<T> ThenBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) + public QueryOverOrderBuilder<T> ThenBy(Expression<Func<T, object>> path) { - return AddOrder(path, orderDelegate); + return new QueryOverOrderBuilder<T>(this, path); } - public QueryOver<T> ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) + public QueryOverOrderBuilder<T> ThenBy(Expression<Func<object>> path) { - return AddOrder(path, orderDelegate); + return new QueryOverOrderBuilder<T>(this, path); } - public IQueryOver<T> Skip(int firstResult) + public QueryOver<T> Skip(int firstResult) { _criteria.SetFirstResult(firstResult); return this; } - public IQueryOver<T> Take(int maxResults) + public QueryOver<T> Take(int maxResults) { _criteria.SetMaxResults(maxResults); return this; } - public IQueryOver<T> Cacheable() + public QueryOver<T> Cacheable() { _criteria.SetCacheable(true); return this; } - public IQueryOver<T> CacheMode(CacheMode cacheMode) + public QueryOver<T> CacheMode(CacheMode cacheMode) { _criteria.SetCacheMode(cacheMode); return this; } - public IQueryOver<T> CacheRegion(string cacheRegion) + public QueryOver<T> CacheRegion(string cacheRegion) { _criteria.SetCacheRegion(cacheRegion); return this; @@ -260,19 +260,7 @@ return this; } - private QueryOver<T> AddOrder(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) - { - _criteria.AddOrder(ExpressionProcessor.ProcessOrder<T>(path, orderDelegate)); - return this; - } - private QueryOver<T> AddOrder(Expression<Func<object>> path, Func<string, Order> orderDelegate) - { - _criteria.AddOrder(ExpressionProcessor.ProcessOrder(path, orderDelegate)); - return this; - } - - ICriteria IQueryOver<T>.UnderlyingCriteria { get { return UnderlyingCriteria; } } @@ -291,17 +279,17 @@ IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<T, object>>[] projections) { return Select(projections); } - IQueryOver<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) - { return OrderBy(path, orderDelegate); } + IQueryOverOrderBuilder<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path) + { return new IQueryOverOrderBuilder<T>(this, path); } - IQueryOver<T> IQueryOver<T>.OrderBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) - { return OrderBy(path, orderDelegate); } + IQueryOverOrderBuilder<T> IQueryOver<T>.OrderBy(Expression<Func<object>> path) + { return new IQueryOverOrderBuilder<T>(this, path); } - IQueryOver<T> IQueryOver<T>.ThenBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) - { return ThenBy(path, orderDelegate); } + IQueryOverOrderBuilder<T> IQueryOver<T>.ThenBy(Expression<Func<T, object>> path) + { return new IQueryOverOrderBuilder<T>(this, path); } - IQueryOver<T> IQueryOver<T>.ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) - { return ThenBy(path, orderDelegate); } + IQueryOverOrderBuilder<T> IQueryOver<T>.ThenBy(Expression<Func<object>> path) + { return new IQueryOverOrderBuilder<T>(this, path); } IQueryOver<T> IQueryOver<T>.Skip(int firstResult) { return Skip(firstResult); } Added: trunk/nhibernate/src/NHibernate/Criterion/QueryOverOrderBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOverOrderBuilder.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOverOrderBuilder.cs 2009-07-30 09:56:14 UTC (rev 4669) @@ -0,0 +1,72 @@ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +using NHibernate.Impl; +using NHibernate.SqlCommand; + +namespace NHibernate.Criterion +{ + + public class QueryOverOrderBuilder<T> : QueryOverOrderBuilderBase<QueryOver<T>, T> + { + + public QueryOverOrderBuilder(QueryOver<T> root, Expression<Func<T, object>> path) : base(root, path) + {} + + public QueryOverOrderBuilder(QueryOver<T> root, Expression<Func<object>> path) : base(root, path) + {} + + } + + public class IQueryOverOrderBuilder<T> : QueryOverOrderBuilderBase<IQueryOver<T>, T> + { + + public IQueryOverOrderBuilder(IQueryOver<T> root, Expression<Func<T, object>> path) : base(root, path) + {} + + public IQueryOverOrderBuilder(IQueryOver<T> root, Expression<Func<object>> path) : base(root, path) + {} + + } + + public class QueryOverOrderBuilderBase<R, T> where R : IQueryOver<T> + { + + protected R root; + protected LambdaExpression path; + + protected QueryOverOrderBuilderBase(R root, Expression<Func<T, object>> path) + { + this.root = root; + this.path = path; + } + + protected QueryOverOrderBuilderBase(R root, Expression<Func<object>> path) + { + this.root = root; + this.path = path; + } + + public R Asc + { + get + { + this.root.UnderlyingCriteria.AddOrder(ExpressionProcessor.ProcessOrder(path, Order.Asc)); + return this.root; + } + } + + public R Desc + { + get + { + this.root.UnderlyingCriteria.AddOrder(ExpressionProcessor.ProcessOrder(path, Order.Desc)); + return this.root; + } + } + + } + +} Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-29 18:46:44 UTC (rev 4668) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-30 09:56:14 UTC (rev 4669) @@ -68,33 +68,29 @@ /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> - /// <param name="orderDelegate">Order delegate (direction)</param> /// <returns>criteria instance</returns> - IQueryOver<T> OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate); + IQueryOverOrderBuilder<T> OrderBy(Expression<Func<T, object>> path); /// <summary> /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> - /// <param name="orderDelegate">Order delegate (direction)</param> /// <returns>criteria instance</returns> - IQueryOver<T> OrderBy(Expression<Func<object>> path, Func<string, Order> orderDelegate); + IQueryOverOrderBuilder<T> OrderBy(Expression<Func<object>> path); /// <summary> /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> - /// <param name="orderDelegate">Order delegate (direction)</param> /// <returns>criteria instance</returns> - IQueryOver<T> ThenBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate); + IQueryOverOrderBuilder<T> ThenBy(Expression<Func<T, object>> path); /// <summary> /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> - /// <param name="orderDelegate">Order delegate (direction)</param> /// <returns>criteria instance</returns> - IQueryOver<T> ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate); + IQueryOverOrderBuilder<T> ThenBy(Expression<Func<object>> path); /// <summary> /// Set the first result to be retrieved Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-07-29 18:46:44 UTC (rev 4668) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-07-30 09:56:14 UTC (rev 4669) @@ -419,6 +419,20 @@ return order; } + /// <summary> + /// Convert a lambda expression to NHibernate Order + /// </summary> + /// <param name="expression">The lambda expression to convert</param> + /// <param name="orderDelegate">The appropriate order delegate (order direction)</param> + /// <returns>NHibernate Order</returns> + public static Order ProcessOrder( LambdaExpression expression, + Func<string, Order> orderDelegate) + { + string property = FindMemberExpression(expression.Body); + Order order = orderDelegate(property); + return order; + } + private static AbstractCriterion ProcessSubqueryExpression(LambdaSubqueryType subqueryType, BinaryExpression be) { Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-29 18:46:44 UTC (rev 4668) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-30 09:56:14 UTC (rev 4669) @@ -492,6 +492,7 @@ <Compile Include="Criterion\GroupedProjection.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Criterion\QueryOverJoinBuilder.cs" /> + <Compile Include="Criterion\QueryOverOrderBuilder.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> <Compile Include="Dialect\InformixDialect1000.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-29 18:46:44 UTC (rev 4668) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-30 09:56:14 UTC (rev 4669) @@ -108,7 +108,7 @@ var actual = s.QueryOver<Person>() .Select(p => p.Age) - .OrderBy(p => p.Age, Order.Asc) + .OrderBy(p => p.Age).Asc .List<int>(); Assert.That(actual[0], Is.EqualTo(20)); @@ -133,7 +133,7 @@ s.QueryOver<Person>(() => personAlias) .Select(p => p.Name, p => personAlias.Age) - .OrderBy(p => p.Age, Order.Asc) + .OrderBy(p => p.Age).Asc .List<object[]>() .Select(props => new { TestName = (string)props[0], Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-29 18:46:44 UTC (rev 4668) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-30 09:56:14 UTC (rev 4669) @@ -251,10 +251,10 @@ Person personAlias = null; IQueryOver<Person> actual = CreateTestQueryOver<Person>(() => personAlias) - .OrderBy(p => p.Name, Order.Asc) - .ThenBy(p => p.Age, Order.Desc) - .ThenBy(() => personAlias.Name, Order.Desc) - .ThenBy(() => personAlias.Age, Order.Asc); + .OrderBy(p => p.Name).Asc + .ThenBy(p => p.Age).Desc + .ThenBy(() => personAlias.Name).Desc + .ThenBy(() => personAlias.Age).Asc; AssertCriteriaAreEqual(expected, actual); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-29 18:46:51
|
Revision: 4668 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4668&view=rev Author: ricbrown Date: 2009-07-29 18:46:44 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Added handling for Lambda syntax allowing path including collections. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-07-28 20:09:38 UTC (rev 4667) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-07-29 18:46:44 UTC (rev 4668) @@ -121,10 +121,15 @@ { MemberExpression memberExpression = (MemberExpression)expression; - if (memberExpression.Expression.NodeType == ExpressionType.MemberAccess) + if (memberExpression.Expression.NodeType == ExpressionType.MemberAccess + || memberExpression.Expression.NodeType == ExpressionType.Call) + { return FindMemberExpression(memberExpression.Expression) + "." + memberExpression.Member.Name; + } else + { return memberExpression.Member.Name; + } } if (expression is UnaryExpression) @@ -149,6 +154,12 @@ return "class"; } + if (methodCallExpression.Method.Name == "get_Item") + return FindMemberExpression(methodCallExpression.Object); + + if (methodCallExpression.Method.Name == "First") + return FindMemberExpression(methodCallExpression.Arguments[0]); + throw new Exception("Unrecognised method call in epression " + expression.ToString()); } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs 2009-07-28 20:09:38 UTC (rev 4667) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs 2009-07-29 18:46:44 UTC (rev 4668) @@ -1,5 +1,6 @@ using System; +using System.Linq; using System.Linq.Expressions; using NHibernate.Criterion; @@ -31,6 +32,22 @@ } [Test] + public void TestFindMemberExpressionSubCollectionIndex() + { + Expression<Func<Person, object>> e = (Person p) => p.PersonList[0].Children; + string property = ExpressionProcessor.FindMemberExpression(e.Body); + Assert.AreEqual("PersonList.Children", property); + } + + [Test] + public void TestFindMemberExpressionSubCollectionExtensionMethod() + { + Expression<Func<Person, object>> e = (Person p) => p.PersonList.First().Children; + string property = ExpressionProcessor.FindMemberExpression(e.Body); + Assert.AreEqual("PersonList.Children", property); + } + + [Test] public void TestEvaluatePropertyExpression() { string testName = "testName"; Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-07-28 20:09:38 UTC (rev 4667) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-07-29 18:46:44 UTC (rev 4668) @@ -25,6 +25,7 @@ public virtual bool IsParent { get; set; } public virtual IEnumerable<Child> Children { get; set; } + public virtual IList<Person> PersonList { get; set; } } public class CustomPerson : Person { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-28 20:09:53
|
Revision: 4667 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4667&view=rev Author: ricbrown Date: 2009-07-28 20:09:38 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Added CacheMode and CacheRegion to IQueryOver. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-28 19:40:32 UTC (rev 4666) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-28 20:09:38 UTC (rev 4667) @@ -111,6 +111,18 @@ return this; } + public IQueryOver<T> CacheMode(CacheMode cacheMode) + { + _criteria.SetCacheMode(cacheMode); + return this; + } + + public IQueryOver<T> CacheRegion(string cacheRegion) + { + _criteria.SetCacheRegion(cacheRegion); + return this; + } + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, @@ -300,6 +312,12 @@ IQueryOver<T> IQueryOver<T>.Cacheable() { return Cacheable(); } + IQueryOver<T> IQueryOver<T>.CacheMode(CacheMode cacheMode) + { return CacheMode(cacheMode); } + + IQueryOver<T> IQueryOver<T>.CacheRegion(string cacheRegion) + { return CacheRegion(cacheRegion); } + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) { return JoinQueryOver(path); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-28 19:40:32 UTC (rev 4666) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-28 20:09:38 UTC (rev 4667) @@ -113,7 +113,19 @@ /// </summary> IQueryOver<T> Cacheable(); + /// <summary> Override the cache mode for this particular query. </summary> + /// <param name="cacheMode">The cache mode to use. </param> + /// <returns> this (for method chaining) </returns> + IQueryOver<T> CacheMode(CacheMode cacheMode); + /// <summary> + /// Set the name of the cache region. + /// </summary> + /// <param name="cacheRegion">the name of a query cache region, or <see langword="null" /> + /// for the default query cache</param> + IQueryOver<T> CacheRegion(string cacheRegion); + + /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-28 19:40:32 UTC (rev 4666) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-28 20:09:38 UTC (rev 4667) @@ -302,11 +302,15 @@ { ICriteria expected = CreateTestCriteria(typeof(Person)) - .SetCacheable(true); + .SetCacheable(true) + .SetCacheMode(CacheMode.Put) + .SetCacheRegion("my cache region"); IQueryOver<Person> actual = CreateTestQueryOver<Person>() - .Cacheable(); + .Cacheable() + .CacheMode(CacheMode.Put) + .CacheRegion("my cache region"); AssertCriteriaAreEqual(expected, actual); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-28 19:40:45
|
Revision: 4666 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4666&view=rev Author: ricbrown Date: 2009-07-28 19:40:32 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Added Cachable() to IQueryOver. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 22:28:49 UTC (rev 4665) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-28 19:40:32 UTC (rev 4666) @@ -105,6 +105,12 @@ return this; } + public IQueryOver<T> Cacheable() + { + _criteria.SetCacheable(true); + return this; + } + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, @@ -291,6 +297,9 @@ IQueryOver<T> IQueryOver<T>.Take(int maxResults) { return Take(maxResults); } + IQueryOver<T> IQueryOver<T>.Cacheable() + { return Cacheable(); } + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) { return JoinQueryOver(path); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 22:28:49 UTC (rev 4665) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-28 19:40:32 UTC (rev 4666) @@ -109,6 +109,11 @@ IQueryOver<T> Take(int maxResults); /// <summary> + /// Enable caching of this query result set + /// </summary> + IQueryOver<T> Cacheable(); + + /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 22:28:49 UTC (rev 4665) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-28 19:40:32 UTC (rev 4666) @@ -297,6 +297,20 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Cachable() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .SetCacheable(true); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Cacheable(); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-27 22:29:02
|
Revision: 4665 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4665&view=rev Author: ricbrown Date: 2009-07-27 22:28:49 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Added paging methods to IQueryOver. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 21:24:37 UTC (rev 4664) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 22:28:49 UTC (rev 4665) @@ -93,6 +93,18 @@ return AddOrder(path, orderDelegate); } + public IQueryOver<T> Skip(int firstResult) + { + _criteria.SetFirstResult(firstResult); + return this; + } + + public IQueryOver<T> Take(int maxResults) + { + _criteria.SetMaxResults(maxResults); + return this; + } + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, @@ -243,6 +255,9 @@ } + ICriteria IQueryOver<T>.UnderlyingCriteria + { get { return UnderlyingCriteria; } } + IQueryOver<T> IQueryOver<T>.And(Expression<Func<T, bool>> expression) { return And(expression); } @@ -270,6 +285,12 @@ IQueryOver<T> IQueryOver<T>.ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate) { return ThenBy(path, orderDelegate); } + IQueryOver<T> IQueryOver<T>.Skip(int firstResult) + { return Skip(firstResult); } + + IQueryOver<T> IQueryOver<T>.Take(int maxResults) + { return Take(maxResults); } + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) { return JoinQueryOver(path); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 21:24:37 UTC (rev 4664) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 22:28:49 UTC (rev 4665) @@ -97,6 +97,18 @@ IQueryOver<T> ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate); /// <summary> + /// Set the first result to be retrieved + /// </summary> + /// <param name="firstResult"></param> + IQueryOver<T> Skip(int firstResult); + + /// <summary> + /// Set a limit upon the number of objects to be retrieved + /// </summary> + /// <param name="maxResults"></param> + IQueryOver<T> Take(int maxResults); + + /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 21:24:37 UTC (rev 4664) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 22:28:49 UTC (rev 4665) @@ -281,6 +281,22 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Paging() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .SetFirstResult(90) + .SetMaxResults(10); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Skip(90) + .Take(10); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-27 21:24:48
|
Revision: 4664 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4664&view=rev Author: ricbrown Date: 2009-07-27 21:24:37 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Exposed underlying ICriteria to allow access to existing ICriteria functionality. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/IQueryOver.cs Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 14:41:38 UTC (rev 4663) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 21:24:37 UTC (rev 4664) @@ -25,6 +25,11 @@ { /// <summary> + /// Access the underlying ICriteria + /// </summary> + ICriteria UnderlyingCriteria { get; } + + /// <summary> /// Add criterion expressed as a lambda expression /// </summary> /// <param name="expression">Lambda expression</param> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-27 14:41:49
|
Revision: 4663 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4663&view=rev Author: ricbrown Date: 2009-07-27 14:41:38 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Added integration test for IQueryOver projections. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate/ISession.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 10:49:18 UTC (rev 4662) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 14:41:38 UTC (rev 4663) @@ -198,6 +198,11 @@ return _criteria.List<T>(); } + public IList<U> List<U>() + { + return _criteria.List<U>(); + } + /// <summary> /// Get an executable instance of <c>IQueryOver<T></c>, /// to actually run the query.</summary> @@ -310,6 +315,9 @@ IList<T> IQueryOver<T>.List() { return List(); } + IList<U> IQueryOver<T>.List<U>() + { return List<U>(); } + } } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 10:49:18 UTC (rev 4662) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 14:41:38 UTC (rev 4663) @@ -195,6 +195,12 @@ /// <returns>The list filled with the results.</returns> IList<T> List(); + /// <summary> + /// Get the results of the root type and fill the <see cref="IList<T>"/> + /// </summary> + /// <returns>The list filled with the results.</returns> + IList<U> List<U>(); + } } Modified: trunk/nhibernate/src/NHibernate/ISession.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ISession.cs 2009-07-27 10:49:18 UTC (rev 4662) +++ trunk/nhibernate/src/NHibernate/ISession.cs 2009-07-27 14:41:38 UTC (rev 4663) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Linq.Expressions; using NHibernate.Engine; using NHibernate.Stat; using NHibernate.Type; @@ -783,13 +784,20 @@ ICriteria CreateCriteria(string entityName, string alias); /// <summary> - /// Creates a new <c>ICriteria<T></c> for the entity class. + /// Creates a new <c>IQueryOver<T></c> for the entity class. /// </summary> /// <typeparam name="T">The entity class</typeparam> /// <returns>An ICriteria<T> object</returns> IQueryOver<T> QueryOver<T>() where T : class; /// <summary> + /// Creates a new <c>IQueryOver<T></c> for the entity class. + /// </summary> + /// <typeparam name="T">The entity class</typeparam> + /// <returns>An ICriteria<T> object</returns> + IQueryOver<T> QueryOver<T>(Expression<Func<T>> alias) where T : class; + + /// <summary> /// Create a new instance of <c>Query</c> for the given query string /// </summary> /// <param name="queryString">A hibernate query string</param> Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-07-27 10:49:18 UTC (rev 4662) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-07-27 14:41:38 UTC (rev 4663) @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Linq.Expressions; using System.Runtime.Serialization; using System.Security.Permissions; using Iesi.Collections; @@ -1881,6 +1882,16 @@ } } + public IQueryOver<T> QueryOver<T>(Expression<Func<T>> alias) where T : class + { + using (new SessionIdLoggingContext(SessionId)) + { + CheckAndUpdateSessionStatus(); + string aliasPath = ExpressionProcessor.FindMemberExpression(alias.Body); + return new QueryOver<T>(new CriteriaImpl(typeof(T), aliasPath, this)); + } + } + public override IList List(CriteriaImpl criteria) { using (new SessionIdLoggingContext(SessionId)) Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-27 10:49:18 UTC (rev 4662) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-07-27 14:41:38 UTC (rev 4663) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using NUnit.Framework; @@ -91,6 +92,59 @@ } } + [Test] + public void Project_SingleProperty() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1", Age = 20 }); + s.Save(new Person() { Name = "test person 2", Age = 30 }); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + var actual = + s.QueryOver<Person>() + .Select(p => p.Age) + .OrderBy(p => p.Age, Order.Asc) + .List<int>(); + + Assert.That(actual[0], Is.EqualTo(20)); + } + } + + [Test] + public void Project_MultipleProperties() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1", Age = 20 }); + s.Save(new Person() { Name = "test person 2", Age = 30 }); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + Person personAlias = null; + var actual = + s.QueryOver<Person>(() => personAlias) + .Select(p => p.Name, + p => personAlias.Age) + .OrderBy(p => p.Age, Order.Asc) + .List<object[]>() + .Select(props => new { + TestName = (string)props[0], + TestAge = (int)props[1], + }); + + Assert.That(actual.ElementAt(0).TestName, Is.EqualTo("test person 1")); + Assert.That(actual.ElementAt(1).TestAge, Is.EqualTo(30)); + } + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-27 10:49:27
|
Revision: 4662 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4662&view=rev Author: ricbrown Date: 2009-07-27 10:49:18 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Corrected syntax for IQueryOver.Select(...) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 09:42:13 UTC (rev 4661) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 10:49:18 UTC (rev 4662) @@ -62,19 +62,14 @@ return Add(expression); } - public QueryOver<T> Select(Expression<Func<object>>[] projections) + public QueryOver<T> Select(params Expression<Func<T, object>>[] projections) { - foreach (var projection in projections) - Select(projection); + List<IProjection> projectionList = new List<IProjection>(); - return this; - } - - public QueryOver<T> Select(Expression<Func<T, object>>[] projections) - { foreach (var projection in projections) - Select(projection); + projectionList.Add(Projections.Property(ExpressionProcessor.FindMemberExpression(projection.Body))); + _criteria.SetProjection(projectionList.ToArray()); return this; } @@ -230,16 +225,6 @@ return this; } - private void Select(Expression<Func<T, object>> projection) - { - _criteria.SetProjection(Projections.Property(ExpressionProcessor.FindMemberExpression(projection.Body))); - } - - private void Select(Expression<Func<object>> projection) - { - _criteria.SetProjection(Projections.Property(ExpressionProcessor.FindMemberExpression(projection.Body))); - } - private QueryOver<T> AddOrder(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) { _criteria.AddOrder(ExpressionProcessor.ProcessOrder<T>(path, orderDelegate)); @@ -268,9 +253,6 @@ IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<T, object>>[] projections) { return Select(projections); } - IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<object>>[] projections) - { return Select(projections); } - IQueryOver<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) { return OrderBy(path, orderDelegate); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 09:42:13 UTC (rev 4661) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 10:49:18 UTC (rev 4662) @@ -60,13 +60,6 @@ IQueryOver<T> Select(params Expression<Func<T, object>>[] projections); /// <summary> - /// Add projection expressed as a lambda expression - /// </summary> - /// <param name="projections">Lambda expressions</param> - /// <returns>criteria instance</returns> - IQueryOver<T> Select(params Expression<Func<object>>[] projections); - - /// <summary> /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 09:42:13 UTC (rev 4661) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 10:49:18 UTC (rev 4662) @@ -264,18 +264,19 @@ { ICriteria expected = CreateTestCriteria(typeof(Person), "personAlias") - .SetProjection(Projections.Property("Name")) - .SetProjection(Projections.Property("Age")) - .SetProjection(Projections.Property("personAlias.Gender")) - .SetProjection(Projections.Property("personAlias.HasCar")); + .SetProjection( + Projections.Property("Name"), + Projections.Property("Age"), + Projections.Property("personAlias.Gender"), + Projections.Property("personAlias.HasCar")); Person personAlias = null; IQueryOver<Person> actual = CreateTestQueryOver<Person>(() => personAlias) .Select(p => p.Name, - p => p.Age) - .Select(() => personAlias.Gender, - () => personAlias.HasCar); + p => p.Age, + p => personAlias.Gender, + p => personAlias.HasCar); AssertCriteriaAreEqual(expected, actual); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-27 09:42:23
|
Revision: 4661 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4661&view=rev Author: ricbrown Date: 2009-07-27 09:42:13 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Added syntax for IQueryOver.Select(...) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-26 17:02:35 UTC (rev 4660) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 09:42:13 UTC (rev 4661) @@ -62,6 +62,22 @@ return Add(expression); } + public QueryOver<T> Select(Expression<Func<object>>[] projections) + { + foreach (var projection in projections) + Select(projection); + + return this; + } + + public QueryOver<T> Select(Expression<Func<T, object>>[] projections) + { + foreach (var projection in projections) + Select(projection); + + return this; + } + public QueryOver<T> OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) { return AddOrder(path, orderDelegate); @@ -214,6 +230,16 @@ return this; } + private void Select(Expression<Func<T, object>> projection) + { + _criteria.SetProjection(Projections.Property(ExpressionProcessor.FindMemberExpression(projection.Body))); + } + + private void Select(Expression<Func<object>> projection) + { + _criteria.SetProjection(Projections.Property(ExpressionProcessor.FindMemberExpression(projection.Body))); + } + private QueryOver<T> AddOrder(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) { _criteria.AddOrder(ExpressionProcessor.ProcessOrder<T>(path, orderDelegate)); @@ -239,6 +265,12 @@ IQueryOver<T> IQueryOver<T>.Where(Expression<Func<bool>> expression) { return Where(expression); } + IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<T, object>>[] projections) + { return Select(projections); } + + IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<object>>[] projections) + { return Select(projections); } + IQueryOver<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path, Func<string, Order> orderDelegate) { return OrderBy(path, orderDelegate); } @@ -293,6 +325,9 @@ IQueryOverJoinBuilder<T> IQueryOver<T>.Full { get { return new IQueryOverJoinBuilder<T>(this, JoinType.FullJoin); } } + IList<T> IQueryOver<T>.List() + { return List(); } + } } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-26 17:02:35 UTC (rev 4660) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 09:42:13 UTC (rev 4661) @@ -53,6 +53,20 @@ IQueryOver<T> Where(Expression<Func<bool>> expression); /// <summary> + /// Add projection expressed as a lambda expression + /// </summary> + /// <param name="projections">Lambda expressions</param> + /// <returns>criteria instance</returns> + IQueryOver<T> Select(params Expression<Func<T, object>>[] projections); + + /// <summary> + /// Add projection expressed as a lambda expression + /// </summary> + /// <param name="projections">Lambda expressions</param> + /// <returns>criteria instance</returns> + IQueryOver<T> Select(params Expression<Func<object>>[] projections); + + /// <summary> /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-26 17:02:35 UTC (rev 4660) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 09:42:13 UTC (rev 4661) @@ -259,6 +259,27 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Project() + { + ICriteria expected = + CreateTestCriteria(typeof(Person), "personAlias") + .SetProjection(Projections.Property("Name")) + .SetProjection(Projections.Property("Age")) + .SetProjection(Projections.Property("personAlias.Gender")) + .SetProjection(Projections.Property("personAlias.HasCar")); + + Person personAlias = null; + IQueryOver<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .Select(p => p.Name, + p => p.Age) + .Select(() => personAlias.Gender, + () => personAlias.HasCar); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-07-26 17:02:45
|
Revision: 4660 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4660&view=rev Author: davybrion Date: 2009-07-26 17:02:35 +0000 (Sun, 26 Jul 2009) Log Message: ----------- applying patch from 'Dima' to fix NH1899 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/GenericMapType.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs Property Changed: ---------------- trunk/nhibernate/src/ Property changes on: trunk/nhibernate/src ___________________________________________________________________ Added: svn:mergeinfo + /branches/2.1.x/nhibernate/src:4659 Modified: trunk/nhibernate/src/NHibernate/Type/GenericMapType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/GenericMapType.cs 2009-07-26 15:43:11 UTC (rev 4659) +++ trunk/nhibernate/src/NHibernate/Type/GenericMapType.cs 2009-07-26 17:02:35 UTC (rev 4660) @@ -71,7 +71,7 @@ IDictionary<TKey, TValue> result = (IDictionary<TKey, TValue>)target; result.Clear(); - IEnumerable iter = (IDictionary)original; + IEnumerable<KeyValuePair<TKey, TValue>> iter = (IDictionary<TKey, TValue>)original; foreach (KeyValuePair<TKey, TValue> me in iter) { TKey key = (TKey)cp.IndexType.Replace(me.Key, null, session, owner, copyCache); Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs 2009-07-26 15:43:11 UTC (rev 4659) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs 2009-07-26 17:02:35 UTC (rev 4660) @@ -1,33 +0,0 @@ - - -using System.Collections; -using System.Collections.Generic; -namespace NHibernate.Test.NHSpecificTest.NH1899 -{ - public class Parent - { - private int id; - private IDictionary<Key, Value> _relations; - - public int Id - { - get { return id; } - set { id = value; } - } - - public IDictionary<Key, Value> Relations { - get { return _relations; } - set { _relations = value; } - } - } - - public enum Key { - One, - Two - } - - public enum Value { - ValOne, - ValTwo - } -} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs (from rev 4659, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs 2009-07-26 17:02:35 UTC (rev 4660) @@ -0,0 +1,33 @@ + + +using System.Collections; +using System.Collections.Generic; +namespace NHibernate.Test.NHSpecificTest.NH1899 +{ + public class Parent + { + private int id; + private IDictionary<Key, Value> _relations; + + public int Id + { + get { return id; } + set { id = value; } + } + + public IDictionary<Key, Value> Relations { + get { return _relations; } + set { _relations = value; } + } + } + + public enum Key { + One, + Two + } + + public enum Value { + ValOne, + ValTwo + } +} \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml 2009-07-26 15:43:11 UTC (rev 4659) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml 2009-07-26 17:02:35 UTC (rev 4660) @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" - namespace="NHibernate.Test.NHSpecificTest.NH1899" default-access="field.camelcase" - default-lazy="false"> - <class name="Parent"> - <id name="Id"> - <generator class="assigned" /> - </id> - <map name="_relations" table="RelationsTable" lazy="false" cascade="all-delete-orphan"> - <key column="ParentID" /> - <index column="KeyId" type="NHibernate.Test.NHSpecificTest.NH1899.Key, NHibernate.Test" /> - <element column="Value" type="NHibernate.Test.NHSpecificTest.NH1899.Value, NHibernate.Test" /> - </map> - </class> -</hibernate-mapping> \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml (from rev 4659, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml 2009-07-26 17:02:35 UTC (rev 4660) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1899" default-access="field.camelcase" + default-lazy="false"> + <class name="Parent"> + <id name="Id"> + <generator class="assigned" /> + </id> + <map name="_relations" table="RelationsTable" lazy="false" cascade="all-delete-orphan"> + <key column="ParentID" /> + <index column="KeyId" type="NHibernate.Test.NHSpecificTest.NH1899.Key, NHibernate.Test" /> + <element column="Value" type="NHibernate.Test.NHSpecificTest.NH1899.Value, NHibernate.Test" /> + </map> + </class> +</hibernate-mapping> \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs 2009-07-26 15:43:11 UTC (rev 4659) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs 2009-07-26 17:02:35 UTC (rev 4660) @@ -1,55 +0,0 @@ -using System.Collections.Generic; - -using NHibernate.Dialect; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH1899 -{ - [TestFixture] - public class SampleTest : BugTestCase - { - protected override void OnSetUp() - { - base.OnSetUp(); - using (ISession session = OpenSession()) - { - Parent entity = new Parent(); - entity.Id = 1; - entity.Relations = new Dictionary<Key, Value>(); - entity.Relations.Add(Key.One, Value.ValOne); - entity.Relations.Add(Key.Two, Value.ValTwo); - session.Save(entity); - session.Flush(); - } - } - - protected override void OnTearDown() - { - base.OnTearDown(); - using (ISession session = OpenSession()) - { - string hql = "from System.Object"; - session.Delete(hql); - session.Flush(); - } - } - - [Test] - public void ShouldNotThrowOnSaveUpdateCopy() - { - Parent entity; - - using (ISession session = OpenSession()) - { - entity = session.Get<Parent>(1); - session.Close(); - session.Dispose(); - } - - using (ISession session2 = OpenSession()) - { - entity = (Parent)session2.SaveOrUpdateCopy(entity); - } - } - } -} Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs (from rev 4659, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs 2009-07-26 17:02:35 UTC (rev 4660) @@ -0,0 +1,55 @@ +using System.Collections.Generic; + +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1899 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + Parent entity = new Parent(); + entity.Id = 1; + entity.Relations = new Dictionary<Key, Value>(); + entity.Relations.Add(Key.One, Value.ValOne); + entity.Relations.Add(Key.Two, Value.ValTwo); + session.Save(entity); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + string hql = "from System.Object"; + session.Delete(hql); + session.Flush(); + } + } + + [Test] + public void ShouldNotThrowOnSaveUpdateCopy() + { + Parent entity; + + using (ISession session = OpenSession()) + { + entity = session.Get<Parent>(1); + session.Close(); + session.Dispose(); + } + + using (ISession session2 = OpenSession()) + { + entity = (Parent)session2.SaveOrUpdateCopy(entity); + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-26 15:43:11 UTC (rev 4659) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-26 17:02:35 UTC (rev 4660) @@ -550,6 +550,8 @@ <Compile Include="NHSpecificTest\NH1868\Model.cs" /> <Compile Include="NHSpecificTest\NH1877\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1877\Person.cs" /> + <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1963,6 +1965,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1868\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1857\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-07-26 15:43:22
|
Revision: 4659 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4659&view=rev Author: davybrion Date: 2009-07-26 15:43:11 +0000 (Sun, 26 Jul 2009) Log Message: ----------- applying patch from 'Dima' to fix NH1899 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Type/GenericMapType.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Type/GenericMapType.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Type/GenericMapType.cs 2009-07-26 15:24:33 UTC (rev 4658) +++ branches/2.1.x/nhibernate/src/NHibernate/Type/GenericMapType.cs 2009-07-26 15:43:11 UTC (rev 4659) @@ -71,7 +71,7 @@ IDictionary<TKey, TValue> result = (IDictionary<TKey, TValue>)target; result.Clear(); - IEnumerable iter = (IDictionary)original; + IEnumerable<KeyValuePair<TKey, TValue>> iter = (IDictionary<TKey, TValue>)original; foreach (KeyValuePair<TKey, TValue> me in iter) { TKey key = (TKey)cp.IndexType.Replace(me.Key, null, session, owner, copyCache); Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/DomainClass.cs 2009-07-26 15:43:11 UTC (rev 4659) @@ -0,0 +1,33 @@ + + +using System.Collections; +using System.Collections.Generic; +namespace NHibernate.Test.NHSpecificTest.NH1899 +{ + public class Parent + { + private int id; + private IDictionary<Key, Value> _relations; + + public int Id + { + get { return id; } + set { id = value; } + } + + public IDictionary<Key, Value> Relations { + get { return _relations; } + set { _relations = value; } + } + } + + public enum Key { + One, + Two + } + + public enum Value { + ValOne, + ValTwo + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/Mappings.hbm.xml 2009-07-26 15:43:11 UTC (rev 4659) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1899" default-access="field.camelcase" + default-lazy="false"> + <class name="Parent"> + <id name="Id"> + <generator class="assigned" /> + </id> + <map name="_relations" table="RelationsTable" lazy="false" cascade="all-delete-orphan"> + <key column="ParentID" /> + <index column="KeyId" type="NHibernate.Test.NHSpecificTest.NH1899.Key, NHibernate.Test" /> + <element column="Value" type="NHibernate.Test.NHSpecificTest.NH1899.Value, NHibernate.Test" /> + </map> + </class> +</hibernate-mapping> \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1899/SampleTest.cs 2009-07-26 15:43:11 UTC (rev 4659) @@ -0,0 +1,55 @@ +using System.Collections.Generic; + +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1899 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + Parent entity = new Parent(); + entity.Id = 1; + entity.Relations = new Dictionary<Key, Value>(); + entity.Relations.Add(Key.One, Value.ValOne); + entity.Relations.Add(Key.Two, Value.ValTwo); + session.Save(entity); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + string hql = "from System.Object"; + session.Delete(hql); + session.Flush(); + } + } + + [Test] + public void ShouldNotThrowOnSaveUpdateCopy() + { + Parent entity; + + using (ISession session = OpenSession()) + { + entity = session.Get<Parent>(1); + session.Close(); + session.Dispose(); + } + + using (ISession session2 = OpenSession()) + { + entity = (Parent)session2.SaveOrUpdateCopy(entity); + } + } + } +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-26 15:24:33 UTC (rev 4658) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-26 15:43:11 UTC (rev 4659) @@ -538,6 +538,8 @@ <Compile Include="NHSpecificTest\NH1868\Model.cs" /> <Compile Include="NHSpecificTest\NH1877\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1877\Person.cs" /> + <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1948,6 +1950,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1868\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1849\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-07-26 15:24:42
|
Revision: 4658 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4658&view=rev Author: davybrion Date: 2009-07-26 15:24:33 +0000 (Sun, 26 Jul 2009) Log Message: ----------- applying patch from Armin Landscheidt to fix NH-1902 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Criterion/Example.cs branches/2.1.x/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs Property Changed: ---------------- branches/2.1.x/nhibernate/src/ Property changes on: branches/2.1.x/nhibernate/src ___________________________________________________________________ Added: svn:mergeinfo + /trunk/nhibernate/src:4657 Modified: branches/2.1.x/nhibernate/src/NHibernate/Criterion/Example.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Criterion/Example.cs 2009-07-26 15:07:33 UTC (rev 4657) +++ branches/2.1.x/nhibernate/src/NHibernate/Criterion/Example.cs 2009-07-26 15:24:33 UTC (rev 4658) @@ -481,7 +481,7 @@ { bool isString = propertyValue is String; crit = (_isLikeEnabled && isString) ? - (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), escapeCharacter, _isIgnoreCaseEnabled) : + (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), _matchMode, escapeCharacter, _isIgnoreCaseEnabled) : new SimpleExpression(propertyName, propertyValue, " = ", _isIgnoreCaseEnabled && isString); } else Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2009-07-26 15:07:33 UTC (rev 4657) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2009-07-26 15:24:33 UTC (rev 4658) @@ -42,6 +42,51 @@ } [Test] + public void TestEnableLikeWithMatchmodeStart() { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { + Componentizable master = GetMaster("hib", null, "open source1"); + ICriteria crit = s.CreateCriteria(typeof(Componentizable)); + Example ex = Example.Create(master).EnableLike(MatchMode.Start); + crit.Add(ex); + IList result = crit.List(); + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Count); + t.Commit(); + } + } + + [Test] + public void TestEnableLikeWithMatchmodeEnd() { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { + Componentizable master = GetMaster("nate", null, "ORM tool1"); + ICriteria crit = s.CreateCriteria(typeof(Componentizable)); + Example ex = Example.Create(master).EnableLike(MatchMode.End); + crit.Add(ex); + IList result = crit.List(); + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Count); + t.Commit(); + } + } + + [Test] + public void TestEnableLikeWithMatchmodeAnywhere() { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { + Componentizable master = GetMaster("bern", null, null); + ICriteria crit = s.CreateCriteria(typeof(Componentizable)); + Example ex = Example.Create(master).EnableLike(MatchMode.Anywhere); + crit.Add(ex); + IList result = crit.List(); + Assert.IsNotNull(result); + Assert.AreEqual(3, result.Count); + t.Commit(); + } + } + + [Test] public void TestJunctionNotExpressionQBE() { using (ISession s = OpenSession()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-07-26 15:07:47
|
Revision: 4657 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4657&view=rev Author: davybrion Date: 2009-07-26 15:07:33 +0000 (Sun, 26 Jul 2009) Log Message: ----------- applying patch from Armin Landscheidt to fix NH-1902 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/Example.cs trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/Example.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-07-19 22:22:59 UTC (rev 4656) +++ trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-07-26 15:07:33 UTC (rev 4657) @@ -481,7 +481,7 @@ { bool isString = propertyValue is String; crit = (_isLikeEnabled && isString) ? - (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), escapeCharacter, _isIgnoreCaseEnabled) : + (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), _matchMode, escapeCharacter, _isIgnoreCaseEnabled) : new SimpleExpression(propertyName, propertyValue, " = ", _isIgnoreCaseEnabled && isString); } else Modified: trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2009-07-19 22:22:59 UTC (rev 4656) +++ trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2009-07-26 15:07:33 UTC (rev 4657) @@ -42,6 +42,51 @@ } [Test] + public void TestEnableLikeWithMatchmodeStart() { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { + Componentizable master = GetMaster("hib", null, "open source1"); + ICriteria crit = s.CreateCriteria(typeof(Componentizable)); + Example ex = Example.Create(master).EnableLike(MatchMode.Start); + crit.Add(ex); + IList result = crit.List(); + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Count); + t.Commit(); + } + } + + [Test] + public void TestEnableLikeWithMatchmodeEnd() { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { + Componentizable master = GetMaster("nate", null, "ORM tool1"); + ICriteria crit = s.CreateCriteria(typeof(Componentizable)); + Example ex = Example.Create(master).EnableLike(MatchMode.End); + crit.Add(ex); + IList result = crit.List(); + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Count); + t.Commit(); + } + } + + [Test] + public void TestEnableLikeWithMatchmodeAnywhere() { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { + Componentizable master = GetMaster("bern", null, null); + ICriteria crit = s.CreateCriteria(typeof(Componentizable)); + Example ex = Example.Create(master).EnableLike(MatchMode.Anywhere); + crit.Add(ex); + IList result = crit.List(); + Assert.IsNotNull(result); + Assert.AreEqual(3, result.Count); + t.Commit(); + } + } + + [Test] public void TestJunctionNotExpressionQBE() { using (ISession s = OpenSession()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-19 22:23:05
|
Revision: 4656 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4656&view=rev Author: fabiomaulo Date: 2009-07-19 22:22:59 +0000 (Sun, 19 Jul 2009) Log Message: ----------- TypeDefinition configuration by code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITypeDefConfiguration.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/TypeDefinitionFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-19 12:35:19 UTC (rev 4655) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-19 22:22:59 UTC (rev 4656) @@ -1,5 +1,6 @@ using System; using NHibernate.Hql; +using NHibernate.Util; namespace NHibernate.Cfg.Loquacious { @@ -60,16 +61,70 @@ entityCacheConfiguration(ecc); if (ecc.Strategy.HasValue) { - configuration.SetCacheConcurrencyStrategy(typeof (TEntity).FullName, EntityCacheUsageParser.ToString(ecc.Strategy.Value), - ecc.RegionName); + configuration.SetCacheConcurrencyStrategy(typeof(TEntity).FullName, EntityCacheUsageParser.ToString(ecc.Strategy.Value), + ecc.RegionName); } foreach (var collection in ecc.Collections) { configuration.SetCollectionCacheConcurrencyStrategy(collection.Key, - EntityCacheUsageParser.ToString(collection.Value.Strategy), - collection.Value.RegionName); + EntityCacheUsageParser.ToString(collection.Value.Strategy), + collection.Value.RegionName); } return configuration; } + + /// <summary> + /// Add a type-definition for mappings. + /// </summary> + /// <typeparam name="TDef">The peristent type.</typeparam> + /// <param name="configuration">The <see cref="Configuration"/> where add the type-definition.</param> + /// <param name="typeDefConfiguration">The custom configuration action.</param> + /// <returns>The <see cref="Configuration"/>.</returns> + /// <remarks> + /// <para> + /// <list type="bullet"> + /// <listheader> + /// <description>Depending on where you will use the type-definition in the mapping the + /// <typeparamref name="TDef"/> can be : + /// </description> + ///</listheader> + ///<item> + /// <term><see cref="NHibernate.UserTypes.IUserType"/></term> + ///</item> + ///<item> + /// <term><see cref="NHibernate.UserTypes.IUserCollectionType"/></term> + ///</item> + ///<item> + /// <term><see cref="NHibernate.UserTypes.IUserVersionType"/></term> + ///</item> + ///<item> + /// <term><see cref="NHibernate.Id.IPersistentIdentifierGenerator"/> </term> + ///</item> + ///</list> + /// </para> + /// </remarks> + public static Configuration TypeDefinition<TDef>(this Configuration configuration, Action<ITypeDefConfigurationProperties> typeDefConfiguration) + where TDef : class + { + if (typeDefConfiguration == null) + { + return configuration; + } + var tdConfiguration = new TypeDefConfigurationProperties<TDef>(); + typeDefConfiguration(tdConfiguration); + if(string.IsNullOrEmpty(tdConfiguration.Alias)) + { + return configuration; + } + var mappings = GetMappings(configuration); + mappings.AddTypeDef(tdConfiguration.Alias, typeof(TDef).AssemblyQualifiedName, tdConfiguration.Properties.ToTypeParameters()); + return configuration; + } + + private static Mappings GetMappings(Configuration configuration) + { + Dialect.Dialect dialect = Dialect.Dialect.GetDialect(configuration.Properties); + return configuration.CreateMappings(dialect); + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITypeDefConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITypeDefConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITypeDefConfiguration.cs 2009-07-19 22:22:59 UTC (rev 4656) @@ -0,0 +1,48 @@ +namespace NHibernate.Cfg.Loquacious +{ + /// <summary> + /// Properties of TypeDef configuration. + /// </summary> + /// <seealso cref="ConfigurationExtensions.TypeDefinition{TDef}<>"/> + public interface ITypeDefConfigurationProperties + { + /// <summary> + /// The key to use the type-definition inside not strongly typed mappings (XML mapping). + /// </summary> + string Alias { get; set; } + + /// <summary> + /// An <see cref="object"/> which public properties are used as + /// type-definition pareneters or null where type-definition does not need parameters or you want use default values. + /// </summary> + /// <remarks> + /// <example> + /// As <paramref name="value"/> an anonimous object can be used: + /// <code> + /// configure.TypeDefinition<TableHiLoGenerator>(c=> + /// { + /// c.Alias = "HighLow"; + /// c.Properties = new {max_lo = 99}; + /// }); + /// </code> + /// </example> + /// </remarks> + object Properties { get; set; } + } + + internal class TypeDefConfigurationProperties<T> : ITypeDefConfigurationProperties + where T: class + { + public TypeDefConfigurationProperties() + { + Alias = typeof(T).Name; + } + + #region Implementation of ITypeDefConfigurationProperties + + public string Alias { get; set; } + public object Properties { get; set; } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-19 12:35:19 UTC (rev 4655) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-19 22:22:59 UTC (rev 4656) @@ -479,6 +479,7 @@ <Compile Include="Cfg\Loquacious\IProxyConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IQueryCacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ITransactionConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\ITypeDefConfiguration.cs" /> <Compile Include="Cfg\Loquacious\MappingsConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ProxyConfiguration.cs" /> <Compile Include="Cfg\SchemaAutoAction.cs" /> Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-07-19 12:35:19 UTC (rev 4655) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-07-19 22:22:59 UTC (rev 4656) @@ -594,5 +594,28 @@ } return result; } + + public static IDictionary<string,string> ToTypeParameters(this object source) + { + if(source == null) + { + return new Dictionary<string, string>(1); + } + var props = source.GetType().GetProperties(); + if(props.Length == 0) + { + return new Dictionary<string, string>(1); + } + var result = new Dictionary<string, string>(props.Length); + foreach (var prop in props) + { + var value = prop.GetValue(source, null); + if (!ReferenceEquals(null, value)) + { + result[prop.Name] = value.ToString(); + } + } + return result; + } } } Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/TypeDefinitionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/TypeDefinitionFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/TypeDefinitionFixture.cs 2009-07-19 22:22:59 UTC (rev 4656) @@ -0,0 +1,28 @@ +using NHibernate.Cfg; +using NHibernate.Cfg.Loquacious; +using NHibernate.Dialect; +using NHibernate.Id; +using NUnit.Framework; + +namespace NHibernate.Test.CfgTest.Loquacious +{ + [TestFixture] + public class TypeDefinitionFixture + { + [Test] + public void AddTypeDef() + { + var configure = new Configuration() + .DataBaseIntegration(db => db.Dialect<MsSql2005Dialect>()); + configure.TypeDefinition<TableHiLoGenerator>(c=> + { + c.Alias = "HighLow"; + c.Properties = new {max_lo = 99}; + }); + var mappings = configure.CreateMappings(Dialect.Dialect.GetDialect(configure.Properties)); + var typeDef = mappings.GetTypeDef("HighLow"); + Assert.That(typeDef, Is.Not.Null); + Assert.That(typeDef.Parameters["max_lo"], Is.EqualTo("99")); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-19 12:35:19 UTC (rev 4655) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-19 22:22:59 UTC (rev 4656) @@ -112,6 +112,7 @@ <Compile Include="CfgTest\Loquacious\EntityCacheConfigurationFixture.cs" /> <Compile Include="CfgTest\Loquacious\EntityToCache.cs" /> <Compile Include="CfgTest\Loquacious\LambdaConfigurationFixture.cs" /> + <Compile Include="CfgTest\Loquacious\TypeDefinitionFixture.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> <Compile Include="CfgTest\SchemaAutoActionFixture.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-19 12:35:20
|
Revision: 4655 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4655&view=rev Author: fabiomaulo Date: 2009-07-19 12:35:19 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Release 2.1.0.GA Added Paths: ----------- tags/2.1.0GA/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-19 12:28:41
|
Revision: 4654 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4654&view=rev Author: fabiomaulo Date: 2009-07-19 12:28:40 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Actualization releasenotes.txt before tag the release. Modified Paths: -------------- branches/2.1.x/nhibernate/releasenotes.txt Modified: branches/2.1.x/nhibernate/releasenotes.txt =================================================================== --- branches/2.1.x/nhibernate/releasenotes.txt 2009-07-18 21:58:15 UTC (rev 4653) +++ branches/2.1.x/nhibernate/releasenotes.txt 2009-07-19 12:28:40 UTC (rev 4654) @@ -33,6 +33,23 @@ * ADOException now use string instead SqlString * IParameterizedType is using IDictionary<string, string> +Build 2.1.0.GA (rev4652) +============================= +** Bug + * [NH-1027] - Querying multiply collections + paging in SQL2005 fail if both has same col name + * [NH-1865] - NHibernate throws InvalidOperationException on Linux/Mono 2.4 + * [NH-1867] - Cannot map a type nested within a generic type + * [NH-1868] - InvalidCastException when using the same filter on two parent entities and a many-to-one + * [NH-1890] - Iesi.Collections file version lower than previous releases + +** Improvement + * [NH-1877] - Support for Projections.GroupBy(IProjection projection) + + +** Patch + * [NH-1872] - OdbcDriver - PrepareSql - SetParameterSizes + * [NH-1876] - Id.TableGenerator fails to apply where clause when selecting the next 'Hi' value (creates infinite loop) + Build 2.1.0.CR1 (rev4578) ============================= ** Bug This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-18 21:58:20
|
Revision: 4653 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4653&view=rev Author: fabiomaulo Date: 2009-07-18 21:58:15 +0000 (Sat, 18 Jul 2009) Log Message: ----------- workaround for Mono (again) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs 2009-07-18 21:53:08 UTC (rev 4652) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs 2009-07-18 21:58:15 UTC (rev 4653) @@ -19,6 +19,7 @@ [XmlIgnore] private IDictionary<string, MetaAttribute> inheritableMetaData; + [XmlIgnore] public virtual IDictionary<string, MetaAttribute> MappedMetaData { get @@ -31,6 +32,7 @@ } } + [XmlIgnore] public IDictionary<string, MetaAttribute> InheritableMetaData { get This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-18 21:53:22
|
Revision: 4652 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4652&view=rev Author: fabiomaulo Date: 2009-07-18 21:53:08 +0000 (Sat, 18 Jul 2009) Log Message: ----------- workaround for Mono (again) Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs 2009-07-17 20:36:48 UTC (rev 4651) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/AbstractDecoratable.cs 2009-07-18 21:53:08 UTC (rev 4652) @@ -19,6 +19,7 @@ [XmlIgnore] private IDictionary<string, MetaAttribute> inheritableMetaData; + [XmlIgnore] public virtual IDictionary<string, MetaAttribute> MappedMetaData { get @@ -31,6 +32,7 @@ } } + [XmlIgnore] public IDictionary<string, MetaAttribute> InheritableMetaData { get This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Urrey <cya...@co...> - 2009-07-18 13:16:11
|
Sexgual Misstakes Men Should Never Make.www[dot]meds11[dot]net |
From: <fab...@us...> - 2009-07-17 20:36:52
|
Revision: 4651 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4651&view=rev Author: fabiomaulo Date: 2009-07-17 20:36:48 +0000 (Fri, 17 Jul 2009) Log Message: ----------- Fix NH-1892 (cache configuration by code) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/EntityCacheConfigurationProperties.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IEntityCacheConfigurationProperties.cs trunk/nhibernate/src/NHibernate/Util/ExpressionsHelper.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityCacheConfigurationFixture.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.hbm.xml trunk/nhibernate/src/NHibernate.Test/UtilityTest/ExpressionsHelperFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-17 17:02:38 UTC (rev 4650) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -1,5 +1,6 @@ using System; using NHibernate.Hql; + namespace NHibernate.Cfg.Loquacious { public static class ConfigurationExtensions @@ -51,5 +52,24 @@ dataBaseIntegration(new DbIntegrationConfigurationProperties(configuration)); return configuration; } + + public static Configuration EntityCache<TEntity>(this Configuration configuration, Action<IEntityCacheConfigurationProperties<TEntity>> entityCacheConfiguration) + where TEntity : class + { + var ecc = new EntityCacheConfigurationProperties<TEntity>(); + entityCacheConfiguration(ecc); + if (ecc.Strategy.HasValue) + { + configuration.SetCacheConcurrencyStrategy(typeof (TEntity).FullName, EntityCacheUsageParser.ToString(ecc.Strategy.Value), + ecc.RegionName); + } + foreach (var collection in ecc.Collections) + { + configuration.SetCollectionCacheConcurrencyStrategy(collection.Key, + EntityCacheUsageParser.ToString(collection.Value.Strategy), + collection.Value.RegionName); + } + return configuration; + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/EntityCacheConfigurationProperties.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/EntityCacheConfigurationProperties.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/EntityCacheConfigurationProperties.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,65 @@ +using System; +using System.Collections; +using System.Linq.Expressions; +using System.Collections.Generic; +using NHibernate.Util; + +namespace NHibernate.Cfg.Loquacious +{ + internal class EntityCacheConfigurationProperties<TEntity> : IEntityCacheConfigurationProperties<TEntity> + where TEntity : class + { + private readonly Dictionary<string, IEntityCollectionCacheConfigurationProperties> collections; + + public EntityCacheConfigurationProperties() + { + collections = new Dictionary<string, IEntityCollectionCacheConfigurationProperties>(10); + Strategy = null; + } + + #region Implementation of IEntityCacheConfigurationProperties + + public EntityCacheUsage? Strategy { set; get; } + public string RegionName { set; get; } + + public void Collection<TCollection>(Expression<Func<TEntity, TCollection>> collectionProperty, + Action<IEntityCollectionCacheConfigurationProperties> collectionCacheConfiguration) + where TCollection : IEnumerable + { + if (collectionProperty == null) + { + throw new ArgumentNullException("collectionProperty"); + } + var mi = ExpressionsHelper.DecodeMemberAccessExpression(collectionProperty); + if(mi.DeclaringType != typeof(TEntity)) + { + throw new ArgumentOutOfRangeException("collectionProperty", "Collection not owned by " + typeof (TEntity).FullName); + } + var ecc = new EntityCollectionCacheConfigurationProperties(); + collectionCacheConfiguration(ecc); + collections.Add(typeof (TEntity).FullName + "." + mi.Name, ecc); + } + + #endregion + + public IDictionary<string, IEntityCollectionCacheConfigurationProperties> Collections + { + get { return collections; } + } + } + + internal class EntityCollectionCacheConfigurationProperties : IEntityCollectionCacheConfigurationProperties + { + public EntityCollectionCacheConfigurationProperties() + { + Strategy = EntityCacheUsage.ReadWrite; + } + + #region Implementation of IEntityCollectionCacheConfigurationProperties + + public EntityCacheUsage Strategy { get; set; } + public string RegionName { get; set; } + + #endregion + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IEntityCacheConfigurationProperties.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IEntityCacheConfigurationProperties.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IEntityCacheConfigurationProperties.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,21 @@ +using System; +using System.Linq.Expressions; +using System.Collections; + +namespace NHibernate.Cfg.Loquacious +{ + public interface IEntityCollectionCacheConfigurationProperties + { + EntityCacheUsage Strategy { get; set; } + string RegionName { get; set; } + } + + public interface IEntityCacheConfigurationProperties<TEntity> where TEntity: class + { + EntityCacheUsage? Strategy { get; set; } + string RegionName { get; set; } + + void Collection<TCollection>(Expression<Func<TEntity, TCollection>> collectionProperty, Action<IEntityCollectionCacheConfigurationProperties> collectionCacheConfiguration) + where TCollection : IEnumerable; + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-17 17:02:38 UTC (rev 4650) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-17 20:36:48 UTC (rev 4651) @@ -464,6 +464,7 @@ <Compile Include="Cfg\Loquacious\CacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> <Compile Include="Cfg\Loquacious\DbIntegrationConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\EntityCacheConfigurationProperties.cs" /> <Compile Include="Cfg\Loquacious\FluentSessionFactoryConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> @@ -472,6 +473,7 @@ <Compile Include="Cfg\Loquacious\IConnectionConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IDbIntegrationConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IDbSchemaIntegrationConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IEntityCacheConfigurationProperties.cs" /> <Compile Include="Cfg\Loquacious\IFluentSessionFactoryConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IMappingsConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IProxyConfiguration.cs" /> @@ -638,6 +640,7 @@ <Compile Include="Type\DbTimestampType.cs" /> <Compile Include="Type\DefaultCollectionTypeFactory.cs" /> <Compile Include="Bytecode\ICollectionTypeFactory.cs" /> + <Compile Include="Util\ExpressionsHelper.cs" /> <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> Added: trunk/nhibernate/src/NHibernate/Util/ExpressionsHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ExpressionsHelper.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Util/ExpressionsHelper.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,19 @@ +using System.Linq.Expressions; +using System.Reflection; +using System; + +namespace NHibernate.Util +{ + public static class ExpressionsHelper + { + public static MemberInfo DecodeMemberAccessExpression<TEntity, TResult>(Expression<Func<TEntity, TResult>> expression) + { + if (expression.Body.NodeType != ExpressionType.MemberAccess) + { + throw new HibernateException( + string.Format("Invalid expression type: Expected ExpressionType.MemberAccess, Found {0}", expression.Body.NodeType)); + } + return ((MemberExpression)expression.Body).Member; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityCacheConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityCacheConfigurationFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityCacheConfigurationFixture.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,83 @@ +using System; +using NHibernate.Cfg; +using NHibernate.Cfg.Loquacious; +using NHibernate.Mapping; +using NUnit.Framework; + +namespace NHibernate.Test.CfgTest.Loquacious +{ + [TestFixture] + public class EntityCacheConfigurationFixture + { + [Test] + public void ConfigureCacheOfClass() + { + Configuration configure = new Configuration().Configure(); + configure.AddResource("NHibernate.Test.CfgTest.Loquacious.EntityToCache.hbm.xml", GetType().Assembly); + + configure.EntityCache<EntityToCache>(ce => + { + ce.Strategy = EntityCacheUsage.NonStrictReadWrite; + ce.RegionName = "MyRegion"; + }); + + var pc = (RootClass) configure.GetClassMapping(typeof (EntityToCache)); + Assert.That(pc.CacheConcurrencyStrategy, + Is.EqualTo(EntityCacheUsageParser.ToString(EntityCacheUsage.NonStrictReadWrite))); + Assert.That(pc.CacheRegionName, Is.EqualTo("MyRegion")); + } + + [Test] + public void ConfigureCacheOfCollection() + { + Configuration configure = new Configuration().Configure(); + configure.AddResource("NHibernate.Test.CfgTest.Loquacious.EntityToCache.hbm.xml", GetType().Assembly); + + configure.EntityCache<EntityToCache>(ce => + { + ce.Strategy = EntityCacheUsage.NonStrictReadWrite; + ce.RegionName = "MyRegion"; + ce.Collection(e => e.Elements, cc => + { + cc.RegionName = "MyCollectionRegion"; + cc.Strategy = + EntityCacheUsage.NonStrictReadWrite; + }); + }); + + Mapping.Collection pc = configure.GetCollectionMapping("NHibernate.Test.CfgTest.Loquacious.EntityToCache.Elements"); + Assert.That(pc.CacheConcurrencyStrategy, + Is.EqualTo(EntityCacheUsageParser.ToString(EntityCacheUsage.NonStrictReadWrite))); + Assert.That(pc.CacheRegionName, Is.EqualTo("MyCollectionRegion")); + } + + [Test] + public void ConfigureCacheOfCollectionWithOutEntity() + { + Configuration configure = new Configuration().Configure(); + configure.AddResource("NHibernate.Test.CfgTest.Loquacious.EntityToCache.hbm.xml", GetType().Assembly); + + configure.EntityCache<EntityToCache>(ce => ce.Collection(e => e.Elements, cc => + { + cc.RegionName = "MyCollectionRegion"; + cc.Strategy = + EntityCacheUsage.NonStrictReadWrite; + })); + + var pc = (RootClass) configure.GetClassMapping(typeof (EntityToCache)); + Assert.That(pc.CacheConcurrencyStrategy, Is.Null); + } + + [Test] + public void NotAllowRelatedCollections() + { + Configuration configure = new Configuration().Configure(); + configure.AddResource("NHibernate.Test.CfgTest.Loquacious.EntityToCache.hbm.xml", GetType().Assembly); + + var exception = + Assert.Throws<ArgumentOutOfRangeException>( + () => configure.EntityCache<EntityToCache>(ce => ce.Collection(e => e.Relation.Elements, cc => { }))); + Assert.That(exception.Message, Text.Contains("Collection not owned by")); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.CfgTest.Loquacious +{ + public class EntityToCache + { + public string Name { get; set; } + public IList<string> Elements { get; set; } + public AnotherEntity Relation { get; set; } + } + + public class AnotherEntity + { + public IList<string> Elements { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/EntityToCache.hbm.xml 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.CfgTest.Loquacious" + assembly="NHibernate.Test"> + + <class name="EntityToCache"> + <id name="Id" type="Int32"> + <generator class="hilo" /> + </id> + + <property name="Name" /> + <bag name="Elements"> + <key column="parentId"/> + <element type="string"/> + </bag> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-17 17:02:38 UTC (rev 4650) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-17 20:36:48 UTC (rev 4651) @@ -109,6 +109,8 @@ <Compile Include="CfgTest\HbmOrderingFixture.cs" /> <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> <Compile Include="CfgTest\Loquacious\ConfigurationFixture.cs" /> + <Compile Include="CfgTest\Loquacious\EntityCacheConfigurationFixture.cs" /> + <Compile Include="CfgTest\Loquacious\EntityToCache.cs" /> <Compile Include="CfgTest\Loquacious\LambdaConfigurationFixture.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> @@ -1368,6 +1370,7 @@ <Compile Include="UserCollection\User.cs" /> <Compile Include="UserCollection\UserCollectionTypeTest.cs" /> <Compile Include="UtilityTest\AssemblyQualifiedTypeNameFixture.cs" /> + <Compile Include="UtilityTest\ExpressionsHelperFixture.cs" /> <Compile Include="UtilityTest\IdentityMapFixture.cs" /> <Compile Include="UtilityTest\IdentityMapSequencedFixture.cs" /> <Compile Include="UtilityTest\JoinedEnumerableFixture.cs" /> @@ -1957,6 +1960,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> + <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1868\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ExpressionsHelperFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ExpressionsHelperFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ExpressionsHelperFixture.cs 2009-07-17 20:36:48 UTC (rev 4651) @@ -0,0 +1,39 @@ +using NHibernate.Util; +using NUnit.Framework; +using System.Collections.Generic; + +namespace NHibernate.Test.UtilityTest +{ + public class TestingClass + { + public int IntProp + { + get { return 0; } + } + + public bool BoolProp + { + get { return false; } + } + + public IEnumerable<string> CollectionProp + { + get { return new string[0]; } + } + } + + [TestFixture] + public class ExpressionsHelperFixture + { + [Test] + public void DecodeMemberAccessExpression() + { + Assert.That(ExpressionsHelper.DecodeMemberAccessExpression<TestingClass, int>(x => x.IntProp), + Is.EqualTo(typeof(TestingClass).GetMember("IntProp")[0])); + Assert.That(ExpressionsHelper.DecodeMemberAccessExpression<TestingClass, bool>(x => x.BoolProp), + Is.EqualTo(typeof(TestingClass).GetMember("BoolProp")[0])); + Assert.That(ExpressionsHelper.DecodeMemberAccessExpression<TestingClass, IEnumerable<string>>(x => x.CollectionProp), + Is.EqualTo(typeof(TestingClass).GetMember("CollectionProp")[0])); + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |