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: <te...@us...> - 2009-07-01 18:37:13
|
Revision: 4555 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4555&view=rev Author: tehlike Date: 2009-07-01 18:37:12 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Marking TimestamperFixture explicit. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/CacheTest/TimestamperFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/CacheTest/TimestamperFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/TimestamperFixture.cs 2009-07-01 18:07:38 UTC (rev 4554) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/TimestamperFixture.cs 2009-07-01 18:37:12 UTC (rev 4555) @@ -10,7 +10,7 @@ [TestFixture] public class TimestamperFixture { - [Test] + [Test,Explicit] public void VerifyIncrease() { long currentTicks = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-07-01 18:08:48
|
Revision: 4554 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4554&view=rev Author: darioquintana Date: 2009-07-01 18:07:38 +0000 (Wed, 01 Jul 2009) Log Message: ----------- merge r4552. NH-645 reopened: not working with AST-Hql. Tests rewritten Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-07-01 17:51:16 UTC (rev 4553) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-07-01 18:07:38 UTC (rev 4554) @@ -1,16 +1,38 @@ using System; using System.Collections; +using Antlr.Runtime.Tree; using NHibernate.Cfg; using NHibernate.Dialect; using NHibernate.Dialect.Function; +using NHibernate.Hql.Ast.ANTLR; +using NHibernate.Hql.Classic; using NUnit.Framework; -using Environment=NHibernate.Cfg.Environment; +using Environment = NHibernate.Cfg.Environment; namespace NHibernate.Test.NHSpecificTest.NH645 { [TestFixture] - public class HQLFunctionFixture : TestCase + public class HqlFunctionWithClassicParser : HQLFunctionFixtureBase { + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(Environment.QueryTranslator, typeof(ClassicQueryTranslatorFactory).AssemblyQualifiedName); + } + } + + [TestFixture, Ignore("Not fixed yet in the AST-HQL parser")] + public class HqlFunctionWithAstHqlParser : HQLFunctionFixtureBase + { + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(Environment.QueryTranslator, typeof(ASTQueryTranslatorFactory).AssemblyQualifiedName); + } + } + + public class HQLFunctionFixtureBase : TestCase + { private bool appliesToThisDialect = true; protected override string MappingsAssembly @@ -18,28 +40,49 @@ get { return "NHibernate.Test"; } } - protected override bool AppliesTo(Dialect.Dialect dialect) + protected override IList Mappings { - return appliesToThisDialect; + get { return new[] { "HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml" }; } } - protected override IList Mappings + protected override bool AppliesTo(Dialect.Dialect dialect) { - get { return new[] {"HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml"}; } + return appliesToThisDialect; } protected override void Configure(Configuration configuration) { if (Dialect is MsSql2005Dialect) - configuration.SetProperty(Environment.Dialect, typeof (CustomDialect).AssemblyQualifiedName); + configuration.SetProperty(Environment.Dialect, typeof(CustomDialect).AssemblyQualifiedName); else appliesToThisDialect = false; } + public void Run(string hql) + { + using (ISession s = OpenSession()) + try + { + s.CreateQuery(hql).List(); + } + catch (Exception ex) + { + if (IsClassicParser) + { + if (ex is QueryException) + Assert.Fail("The parser think that 'freetext' is a boolean function"); + } + else //Hql-Parser + { + if (ex is RewriteEmptyStreamException || ex is InvalidCastException) + Assert.Fail("The parser think that 'freetext' is a boolean function"); + } + } + } + /// <summary> /// Just test the parser can compile, and SqlException is expected. /// </summary> - [Test] public void SimpleWhere() { @@ -57,21 +100,6 @@ { Run("from Animal a where freetext(a.Description, 'hey apple car') AND a.Description <> 'foo'"); } - - - public void Run(string hql) - { - using(ISession s = OpenSession()) - try - { - s.CreateQuery(hql).List(); - } - catch (Exception ex) - { - if (ex is QueryException) - Assert.Fail("The parser think that 'freetext' is a boolean function"); - } - } } public class CustomDialect : MsSql2005Dialect This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-01 17:51:19
|
Revision: 4553 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4553&view=rev Author: fabiomaulo Date: 2009-07-01 17:51:16 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Fluent configuration (Test for ConnectionStringName) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 17:43:35 UTC (rev 4552) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 17:51:16 UTC (rev 4553) @@ -130,5 +130,18 @@ Assert.That(cfg.Properties[Environment.ConnectionString], Is.EqualTo("Data Source=(local);Initial Catalog=nhibernate;Integrated Security=True")); } + + + [Test] + public void UseConnectionStringName() + { + var cfg = new Configuration(); + cfg.SessionFactory() + .Integrate + .Connected + .ByAppConfing("MyName"); + + Assert.That(cfg.Properties[Environment.ConnectionStringName], Is.EqualTo("MyName")); + } } } \ 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: <dar...@us...> - 2009-07-01 17:44:16
|
Revision: 4552 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4552&view=rev Author: darioquintana Date: 2009-07-01 17:43:35 +0000 (Wed, 01 Jul 2009) Log Message: ----------- NH-645 reopened: not working with AST-Hql. Tests rewritten Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-07-01 16:31:18 UTC (rev 4551) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-07-01 17:43:35 UTC (rev 4552) @@ -1,16 +1,38 @@ using System; using System.Collections; +using Antlr.Runtime.Tree; using NHibernate.Cfg; using NHibernate.Dialect; using NHibernate.Dialect.Function; +using NHibernate.Hql.Ast.ANTLR; +using NHibernate.Hql.Classic; using NUnit.Framework; using Environment=NHibernate.Cfg.Environment; namespace NHibernate.Test.NHSpecificTest.NH645 { [TestFixture] - public class HQLFunctionFixture : TestCase + public class HqlFunctionWithClassicParser : HQLFunctionFixtureBase { + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(Environment.QueryTranslator, typeof (ClassicQueryTranslatorFactory).AssemblyQualifiedName); + } + } + + [TestFixture, Ignore("Not fixed yet in the AST-HQL parser")] + public class HqlFunctionWithAstHqlParser : HQLFunctionFixtureBase + { + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(Environment.QueryTranslator, typeof (ASTQueryTranslatorFactory).AssemblyQualifiedName); + } + } + + public class HQLFunctionFixtureBase : TestCase + { private bool appliesToThisDialect = true; protected override string MappingsAssembly @@ -18,14 +40,14 @@ get { return "NHibernate.Test"; } } - protected override bool AppliesTo(Dialect.Dialect dialect) + protected override IList Mappings { - return appliesToThisDialect; + get { return new[] {"HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml"}; } } - protected override IList Mappings + protected override bool AppliesTo(Dialect.Dialect dialect) { - get { return new[] {"HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml"}; } + return appliesToThisDialect; } protected override void Configure(Configuration configuration) @@ -36,10 +58,31 @@ appliesToThisDialect = false; } + public void Run(string hql) + { + using (ISession s = OpenSession()) + try + { + s.CreateQuery(hql).List(); + } + catch (Exception ex) + { + if (IsClassicParser) + { + if (ex is QueryException) + Assert.Fail("The parser think that 'freetext' is a boolean function"); + } + else //Hql-Parser + { + if (ex is RewriteEmptyStreamException || ex is InvalidCastException) + Assert.Fail("The parser think that 'freetext' is a boolean function"); + } + } + } + /// <summary> /// Just test the parser can compile, and SqlException is expected. /// </summary> - [Test] public void SimpleWhere() { @@ -57,21 +100,6 @@ { Run("from Animal a where freetext(a.Description, 'hey apple car') AND a.Description <> 'foo'"); } - - - public void Run(string hql) - { - using(ISession s = OpenSession()) - try - { - s.CreateQuery(hql).List(); - } - catch (Exception ex) - { - if (ex is QueryException) - Assert.Fail("The parser think that 'freetext' is a boolean function"); - } - } } public class CustomDialect : MsSql2005Dialect This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-01 16:31:21
|
Revision: 4551 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4551&view=rev Author: fabiomaulo Date: 2009-07-01 16:31:18 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Fluent configuration implemented Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -4,7 +4,7 @@ { public static IFluentSessionFactoryConfiguration SessionFactory(this Configuration configuration) { - return null; + return new FluentSessionFactoryConfiguration(configuration); } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -0,0 +1,470 @@ +using System.Data; +using System.Data.Common; +using NHibernate.AdoNet; +using NHibernate.Bytecode; +using NHibernate.Cache; +using NHibernate.Connection; +using NHibernate.Driver; +using NHibernate.Exceptions; +using NHibernate.Hql; +using NHibernate.Transaction; + +namespace NHibernate.Cfg.Loquacious +{ + internal class FluentSessionFactoryConfiguration : IFluentSessionFactoryConfiguration + { + private readonly Configuration configuration; + + public FluentSessionFactoryConfiguration(Configuration configuration) + { + this.configuration = configuration; + Integrate = new DbIntegrationConfiguration(configuration); + Caching = new CacheConfiguration(this); + Proxy = new ProxyConfiguration(this); + GeneratingCollections = new CollectionFactoryConfiguration(this); + Mapping = new MappingsConfiguration(this); + } + + internal Configuration Configuration + { + get { return configuration; } + } + + #region Implementation of IFluentSessionFactoryConfiguration + + public IFluentSessionFactoryConfiguration Named(string sessionFactoryName) + { + configuration.SetProperty(Environment.SessionFactoryName, sessionFactoryName); + return this; + } + + public IDbIntegrationConfiguration Integrate { get; private set; } + + public ICacheConfiguration Caching { get; private set; } + + public IFluentSessionFactoryConfiguration GenerateStatistics() + { + configuration.SetProperty(Environment.GenerateStatistics, "true"); + return this; + } + + public IFluentSessionFactoryConfiguration Using(EntityMode entityMode) + { + configuration.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(entityMode)); + return this; + } + + public IFluentSessionFactoryConfiguration ParsingHqlThrough<TQueryTranslator>() + where TQueryTranslator : IQueryTranslatorFactory + { + configuration.SetProperty(Environment.QueryTranslator, typeof (TQueryTranslator).AssemblyQualifiedName); + return this; + } + + public IProxyConfiguration Proxy { get; private set; } + public ICollectionFactoryConfiguration GeneratingCollections { get; private set; } + public IMappingsConfiguration Mapping { get; private set; } + + #endregion + } + + internal class DbIntegrationConfiguration : IDbIntegrationConfiguration + { + private readonly Configuration configuration; + + public DbIntegrationConfiguration(Configuration configuration) + { + this.configuration = configuration; + Connected = new ConnectionConfiguration(this); + BatchingQueries = new BatcherConfiguration(this); + Transactions = new TransactionConfiguration(this); + CreateCommands = new CommandsConfiguration(this); + Schema = new DbSchemaIntegrationConfiguration(this); + } + + public Configuration Configuration + { + get { return configuration; } + } + + #region Implementation of IDbIntegrationConfiguration + + public IDbIntegrationConfiguration Using<TDialect>() where TDialect : Dialect.Dialect + { + configuration.SetProperty(Environment.Dialect, typeof (TDialect).AssemblyQualifiedName); + return this; + } + + public IDbIntegrationConfiguration DisableKeywordsAutoImport() + { + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "none"); + return this; + } + + public IDbIntegrationConfiguration AutoQuoteKeywords() + { + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + return this; + } + + public IDbIntegrationConfiguration LogSqlInConsole() + { + configuration.SetProperty(Environment.ShowSql, "true"); + return this; + } + + public IDbIntegrationConfiguration DisableLogFormatedSql() + { + configuration.SetProperty(Environment.FormatSql, "false"); + return this; + } + + public IConnectionConfiguration Connected { get; private set; } + public IBatcherConfiguration BatchingQueries { get; private set; } + public ITransactionConfiguration Transactions { get; private set; } + + public ICommandsConfiguration CreateCommands { get; private set; } + + public IDbSchemaIntegrationConfiguration Schema { get; private set; } + + #endregion + } + + internal class DbSchemaIntegrationConfiguration : IDbSchemaIntegrationConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public DbSchemaIntegrationConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IDbSchemaIntegrationConfiguration + + public IDbIntegrationConfiguration Recreating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create-drop"); + return dbc; + } + + public IDbIntegrationConfiguration Creating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "create"); + return dbc; + } + + public IDbIntegrationConfiguration Updating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "update"); + return dbc; + } + + public IDbIntegrationConfiguration Validating() + { + dbc.Configuration.SetProperty(Environment.Hbm2ddlAuto, "validate"); + return dbc; + } + + #endregion + } + + internal class CommandsConfiguration : ICommandsConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public CommandsConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of ICommandsConfiguration + + public ICommandsConfiguration Preparing() + { + dbc.Configuration.SetProperty(Environment.PrepareSql, "true"); + return this; + } + + public ICommandsConfiguration WithTimeout(int seconds) + { + dbc.Configuration.SetProperty(Environment.CommandTimeout, seconds.ToString()); + return this; + } + + public ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() + where TExceptionConverter : ISQLExceptionConverter + { + dbc.Configuration.SetProperty(Environment.SqlExceptionConverter, typeof (TExceptionConverter).AssemblyQualifiedName); + return this; + } + + public ICommandsConfiguration AutoCommentingSql() + { + dbc.Configuration.SetProperty(Environment.UseSqlComments, "true"); + return this; + } + + public IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions) + { + dbc.Configuration.SetProperty(Environment.QuerySubstitutions, csvQuerySubstitutions); + return dbc; + } + + public IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions() + { + return dbc; + } + + public ICommandsConfiguration WithMaximumDepthOfOuterJoinFetching(byte maxFetchDepth) + { + dbc.Configuration.SetProperty(Environment.MaxFetchDepth, maxFetchDepth.ToString()); + return this; + } + + #endregion + } + + internal class TransactionConfiguration : ITransactionConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public TransactionConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of ITransactionConfiguration + + public IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory + { + dbc.Configuration.SetProperty(Environment.TransactionStrategy, typeof (TFactory).AssemblyQualifiedName); + return dbc; + } + + #endregion + } + + internal class BatcherConfiguration : IBatcherConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public BatcherConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IBatcherConfiguration + + public IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory + { + dbc.Configuration.SetProperty(Environment.BatchStrategy, typeof (TBatcher).AssemblyQualifiedName); + return this; + } + + public IDbIntegrationConfiguration Each(short batchSize) + { + dbc.Configuration.SetProperty(Environment.BatchSize, batchSize.ToString()); + return dbc; + } + + #endregion + } + + internal class ConnectionConfiguration : IConnectionConfiguration + { + private readonly DbIntegrationConfiguration dbc; + + public ConnectionConfiguration(DbIntegrationConfiguration dbc) + { + this.dbc = dbc; + } + + #region Implementation of IConnectionConfiguration + + public IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider + { + dbc.Configuration.SetProperty(Environment.ConnectionProvider, typeof (TProvider).AssemblyQualifiedName); + return this; + } + + public IConnectionConfiguration By<TDriver>() where TDriver : IDriver + { + dbc.Configuration.SetProperty(Environment.ConnectionDriver, typeof (TDriver).AssemblyQualifiedName); + return this; + } + + public IConnectionConfiguration With(IsolationLevel level) + { + dbc.Configuration.SetProperty(Environment.Isolation, level.ToString()); + return this; + } + + public IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode) + { + dbc.Configuration.SetProperty(Environment.ReleaseConnections, ConnectionReleaseModeParser.ToString(releaseMode)); + return this; + } + + public IDbIntegrationConfiguration Using(string connectionString) + { + dbc.Configuration.SetProperty(Environment.ConnectionString, connectionString); + return dbc; + } + + public IDbIntegrationConfiguration Using(DbConnectionStringBuilder connectionStringBuilder) + { + dbc.Configuration.SetProperty(Environment.ConnectionString, connectionStringBuilder.ConnectionString); + return dbc; + } + + public IDbIntegrationConfiguration ByAppConfing(string connectionStringName) + { + dbc.Configuration.SetProperty(Environment.ConnectionStringName, connectionStringName); + return dbc; + } + + #endregion + } + + internal class CacheConfiguration : ICacheConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public CacheConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + Queries = new QueryCacheConfiguration(this); + } + + internal Configuration Configuration + { + get { return fc.Configuration; } + } + + #region Implementation of ICacheConfiguration + + public ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider + { + fc.Configuration.SetProperty(Environment.CacheProvider, typeof (TProvider).AssemblyQualifiedName); + return this; + } + + public ICacheConfiguration PrefixingRegionsWith(string regionPrefix) + { + fc.Configuration.SetProperty(Environment.CacheRegionPrefix, regionPrefix); + return this; + } + + public ICacheConfiguration UsingMinimalPuts() + { + fc.Configuration.SetProperty(Environment.UseMinimalPuts, "true"); + return this; + } + + public IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds) + { + fc.Configuration.SetProperty(Environment.CacheDefaultExpiration, seconds.ToString()); + return fc; + } + + public IQueryCacheConfiguration Queries { get; private set; } + + #endregion + } + + internal class QueryCacheConfiguration : IQueryCacheConfiguration + { + private readonly CacheConfiguration cc; + + public QueryCacheConfiguration(CacheConfiguration cc) + { + this.cc = cc; + } + + #region Implementation of IQueryCacheConfiguration + + public ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache + { + cc.Configuration.SetProperty(Environment.QueryCacheFactory, typeof (TFactory).AssemblyQualifiedName); + return cc; + } + + #endregion + } + + internal class ProxyConfiguration : IProxyConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public ProxyConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of IProxyConfiguration + + public IProxyConfiguration DisableValidation() + { + fc.Configuration.SetProperty(Environment.UseProxyValidator, "false"); + return this; + } + + public IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() + where TProxyFactoryFactory : IProxyFactoryFactory + { + fc.Configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof (TProxyFactoryFactory).AssemblyQualifiedName); + return fc; + } + + #endregion + } + + internal class CollectionFactoryConfiguration : ICollectionFactoryConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public CollectionFactoryConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of ICollectionFactoryConfiguration + + public IFluentSessionFactoryConfiguration Through<TCollecionsFactory>() + where TCollecionsFactory : ICollectionTypeFactory + { + fc.Configuration.SetProperty(Environment.CollectionTypeFactoryClass, + typeof (TCollecionsFactory).AssemblyQualifiedName); + return fc; + } + + #endregion + } + + internal class MappingsConfiguration : IMappingsConfiguration + { + private readonly FluentSessionFactoryConfiguration fc; + + public MappingsConfiguration(FluentSessionFactoryConfiguration parent) + { + fc = parent; + } + + #region Implementation of IMappingsConfiguration + + public IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName) + { + fc.Configuration.SetProperty(Environment.DefaultCatalog, defaultCatalogName); + return this; + } + + public IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName) + { + fc.Configuration.SetProperty(Environment.DefaultSchema, defaultSchemaName); + return fc; + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -95,7 +95,7 @@ } else { - releaseMode = ParseConnectionReleaseMode(releaseModeName); + releaseMode = ConnectionReleaseModeParser.Convert(releaseModeName); } settings.ConnectionReleaseMode = releaseMode; @@ -329,21 +329,6 @@ } } - private static ConnectionReleaseMode ParseConnectionReleaseMode(string name) - { - switch (name) - { - case "after_statement": - throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate"); - case "after_transaction": - return ConnectionReleaseMode.AfterTransaction; - case "on_close": - return ConnectionReleaseMode.OnClose; - default: - throw new HibernateException("could not determine appropriate connection release mode [" + name + "]"); - } - } - // visibility changed and static modifier added until complete H3.2 porting of SettingsFactory private static IQueryTranslatorFactory CreateQueryTranslatorFactory(IDictionary<string, string> properties) { Modified: trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/ConnectionReleaseMode.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -1,3 +1,5 @@ +using System; + namespace NHibernate { public enum ConnectionReleaseMode @@ -5,7 +7,38 @@ AfterStatement, AfterTransaction, OnClose + } - // Parse method moved to SettingsFactory + public static class ConnectionReleaseModeParser + { + public static ConnectionReleaseMode Convert(string value) + { + switch (value) + { + case "after_statement": + throw new HibernateException("aggressive connection release (after_statement) not supported by NHibernate"); + case "after_transaction": + return ConnectionReleaseMode.AfterTransaction; + case "on_close": + return ConnectionReleaseMode.OnClose; + default: + throw new HibernateException("could not determine appropriate connection release mode [" + value + "]"); + } + } + + public static string ToString(ConnectionReleaseMode value) + { + switch (value) + { + case ConnectionReleaseMode.AfterStatement: + return "after_statement"; + case ConnectionReleaseMode.AfterTransaction: + return "after_transaction" ; + case ConnectionReleaseMode.OnClose: + return "on_close"; + default: + throw new ArgumentOutOfRangeException("value"); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-01 16:31:18 UTC (rev 4551) @@ -460,6 +460,7 @@ <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> + <Compile Include="Cfg\Loquacious\FluentSessionFactoryConfiguration.cs" /> <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICollectionFactoryConfiguration.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 13:46:24 UTC (rev 4550) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-07-01 16:31:18 UTC (rev 4551) @@ -10,12 +10,15 @@ using NHibernate.Exceptions; using NHibernate.Hql.Classic; using NHibernate.Type; +using NUnit.Framework; namespace NHibernate.Test.CfgTest.Loquacious { + [TestFixture] public class ConfigurationFixture { - public void ProofOfConcept() + [Test] + public void CompleteConfiguration() { // Here I'm configuring near all properties outside the scope of Configuration class // Using the Configuration class the user can add mappings and configure listeners @@ -42,27 +45,67 @@ .AutoQuoteKeywords() .BatchingQueries .Through<SqlClientBatchingBatcherFactory>() - .Each(10) + .Each(15) .Connected .Through<DebugConnectionProvider>() .By<SqlClientDriver>() .Releasing(ConnectionReleaseMode.AfterTransaction) .With(IsolationLevel.ReadCommitted) - .Using("The connection string but it has some overload") + .Using("The connection string") .CreateCommands .AutoCommentingSql() .ConvertingExceptionsThrough<SQLStateConverter>() .Preparing() .WithTimeout(10) - .WithMaximumDepthOfOuterJoinFetching(10) + .WithMaximumDepthOfOuterJoinFetching(11) .WithHqlToSqlSubstitutions("true 1, false 0, yes 'Y', no 'N'") .Schema .Validating() ; + Assert.That(cfg.Properties[Environment.SessionFactoryName], Is.EqualTo("SomeName")); + Assert.That(cfg.Properties[Environment.CacheProvider], + Is.EqualTo(typeof(HashtableCacheProvider).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.CacheRegionPrefix], Is.EqualTo("xyz")); + Assert.That(cfg.Properties[Environment.QueryCacheFactory], + Is.EqualTo(typeof(StandardQueryCache).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.UseMinimalPuts], Is.EqualTo("true")); + Assert.That(cfg.Properties[Environment.CacheDefaultExpiration], Is.EqualTo("15")); + Assert.That(cfg.Properties[Environment.CollectionTypeFactoryClass], + Is.EqualTo(typeof(DefaultCollectionTypeFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.UseProxyValidator], Is.EqualTo("false")); + Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], + Is.EqualTo(typeof(ProxyFactoryFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.QueryTranslator], + Is.EqualTo(typeof(ClassicQueryTranslatorFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.DefaultCatalog], Is.EqualTo("MyCatalog")); + Assert.That(cfg.Properties[Environment.DefaultSchema], Is.EqualTo("MySche")); + Assert.That(cfg.Properties[Environment.Dialect], + Is.EqualTo(typeof(MsSql2000Dialect).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.Hbm2ddlKeyWords], Is.EqualTo("auto-quote")); + Assert.That(cfg.Properties[Environment.BatchStrategy], + Is.EqualTo(typeof(SqlClientBatchingBatcherFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.BatchSize], Is.EqualTo("15")); + Assert.That(cfg.Properties[Environment.ConnectionProvider], + Is.EqualTo(typeof(DebugConnectionProvider).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.ConnectionDriver], + Is.EqualTo(typeof(SqlClientDriver).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.ReleaseConnections], + Is.EqualTo(ConnectionReleaseModeParser.ToString(ConnectionReleaseMode.AfterTransaction))); + Assert.That(cfg.Properties[Environment.Isolation], Is.EqualTo("ReadCommitted")); + Assert.That(cfg.Properties[Environment.ConnectionString], Is.EqualTo("The connection string")); + Assert.That(cfg.Properties[Environment.UseSqlComments], Is.EqualTo("true")); + Assert.That(cfg.Properties[Environment.SqlExceptionConverter], + Is.EqualTo(typeof(SQLStateConverter).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.PrepareSql], Is.EqualTo("true")); + Assert.That(cfg.Properties[Environment.CommandTimeout], Is.EqualTo("10")); + Assert.That(cfg.Properties[Environment.MaxFetchDepth], Is.EqualTo("11")); + Assert.That(cfg.Properties[Environment.QuerySubstitutions], Is.EqualTo("true 1, false 0, yes 'Y', no 'N'")); + Assert.That(cfg.Properties[Environment.Hbm2ddlAuto], Is.EqualTo("validate")); } - public void ProofOfConceptMinimalConfiguration() + [Test] + public void UseDbConfigurationStringBuilder() { // This is a possible minimal configuration // in this case we must define best default properties for each dialect @@ -79,6 +122,13 @@ InitialCatalog = "nhibernate", IntegratedSecurity = true }); + + Assert.That(cfg.Properties[Environment.ProxyFactoryFactoryClass], + Is.EqualTo(typeof (ProxyFactoryFactory).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.Dialect], + Is.EqualTo(typeof(MsSql2005Dialect).AssemblyQualifiedName)); + Assert.That(cfg.Properties[Environment.ConnectionString], + Is.EqualTo("Data Source=(local);Initial Catalog=nhibernate;Integrated Security=True")); } } } \ 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: <te...@us...> - 2009-07-01 14:54:13
|
Revision: 4550 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4550&view=rev Author: tehlike Date: 2009-07-01 13:46:24 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Changes to build files to produce xml outputs for tests. Modified Paths: -------------- trunk/nhibernate/build-common/common-project.xml trunk/nhibernate/build-common/common.xml trunk/nhibernate/default.build trunk/nhibernate/teamcity.build Modified: trunk/nhibernate/build-common/common-project.xml =================================================================== --- trunk/nhibernate/build-common/common-project.xml 2009-06-30 17:32:16 UTC (rev 4549) +++ trunk/nhibernate/build-common/common-project.xml 2009-07-01 13:46:24 UTC (rev 4550) @@ -222,8 +222,9 @@ <target name="common.run-tests" description="Run NUnit tests"> - <exec program="${root.dir}/Tools/nunit/nunit-console-x86.exe"> - <arg line="${bin.dir}/${project::get-name()}.dll" /> + <call target="common.find-nunit" unless="${property::exists('nunit.found')}" /> + <exec program="${nunit-console}"> + <arg line="${bin.dir}/${project::get-name()}.dll /xml:${testresults.dir}/${project::get-name()}.dll-results.xml " /> </exec> <!--<nunit2> Modified: trunk/nhibernate/build-common/common.xml =================================================================== --- trunk/nhibernate/build-common/common.xml 2009-06-30 17:32:16 UTC (rev 4549) +++ trunk/nhibernate/build-common/common.xml 2009-07-01 13:46:24 UTC (rev 4550) @@ -174,8 +174,12 @@ <property name="build.root.dir" value="${root.dir}/build/${build.name}" /> <property name="build.dir" value="${build.root.dir}" /> <property name="bin.dir" value="${build.dir}/bin/${nant.settings.currentframework}" dynamic="true" /> + <property name="testresults.dir" value="${bin.dir}/test-results" /> + <property name="tools.dir" value="${root.dir}/Tools"/> </target> + + <target name="set-framework-configuration"> <if test="${not(target::exists('set-'+framework::get-target-framework()+'-framework-configuration'))}"> <fail message="The '${framework::get-target-framework()}' framework is not supported by this version of NHibernate." /> @@ -242,5 +246,9 @@ </fileset> <resourcefileset id="project.resources" /> </target> + + <target name="common.find-nunit"> + <property name="nunit-console" value="${tools.dir}/NUnit/nunit-console-x86.exe" /> + </target> </project> Modified: trunk/nhibernate/default.build =================================================================== --- trunk/nhibernate/default.build 2009-06-30 17:32:16 UTC (rev 4549) +++ trunk/nhibernate/default.build 2009-07-01 13:46:24 UTC (rev 4550) @@ -47,6 +47,7 @@ <target name="prepare-build-directory" depends="init"> <mkdir dir="${bin.dir}" /> + <mkdir dir="${testresults.dir}" /> <call target="copy-referenced-assemblies" /> </target> Modified: trunk/nhibernate/teamcity.build =================================================================== --- trunk/nhibernate/teamcity.build 2009-06-30 17:32:16 UTC (rev 4549) +++ trunk/nhibernate/teamcity.build 2009-07-01 13:46:24 UTC (rev 4550) @@ -2,10 +2,9 @@ <project name="NHibernate TeamCity Build" xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd" default="clean-configure-test"> <property name="root.dir" value="." /> <include buildfile="${root.dir}/default.build" /> - <!-- <if test="${not property::exists('CCNetLabel') and not property::exists('build.number')}"> <fail>This build file is for use with CruiseControl.NET or TeamCity</fail> - </if>--> + </if> <property name="build.number" value="${CCNetLabel}" if="${property::exists('CCNetLabel')}" /> @@ -13,8 +12,6 @@ </target> <target name="copy-teamcity-configuration"> - <copy file="${teamcity.dotnet.nunitaddin}-2.5.0.dll" todir="${root.dir}/Tools/nunit/addins" /> - <copy file="${teamcity.dotnet.nunitaddin}-2.5.0.pdb" todir="${root.dir}/Tools/nunit/addins" /> <copy file="build-common/teamcity-hibernate.cfg.xml" tofile="${bin.dir}/hibernate.cfg.xml" /> </target> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Shutts<ver...@hi...> - 2009-07-01 08:18:05
|
Oral sex Positions For Maximuum Pleeasure www. med72. com. Cash on offer for SS Koreans hwo stay away from prostitutes |
From: <fab...@us...> - 2009-06-30 17:32:18
|
Revision: 4549 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4549&view=rev Author: fabiomaulo Date: 2009-06-30 17:32:16 +0000 (Tue, 30 Jun 2009) Log Message: ----------- Minor (added one entry point for fluent conf) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ConfigurationExtensions.cs 2009-06-30 17:32:16 UTC (rev 4549) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.Loquacious +{ + public static class ConfigurationExtensions + { + public static IFluentSessionFactoryConfiguration SessionFactory(this Configuration configuration) + { + return null; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-29 20:56:51 UTC (rev 4548) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-30 17:32:16 UTC (rev 4549) @@ -459,6 +459,7 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ICollectionFactoryConfiguration.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-29 20:56:51 UTC (rev 4548) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-30 17:32:16 UTC (rev 4549) @@ -3,6 +3,7 @@ using NHibernate.AdoNet; using NHibernate.ByteCode.LinFu; using NHibernate.Cache; +using NHibernate.Cfg; using NHibernate.Cfg.Loquacious; using NHibernate.Dialect; using NHibernate.Driver; @@ -18,8 +19,8 @@ { // Here I'm configuring near all properties outside the scope of Configuration class // Using the Configuration class the user can add mappings and configure listeners - IFluentSessionFactoryConfiguration sfc= null; - sfc.Named("SomeName") + var cfg = new Configuration(); + cfg.SessionFactory().Named("SomeName") .Caching .Through<HashtableCacheProvider>() .PrefixingRegionsWith("xyz") @@ -66,8 +67,8 @@ // This is a possible minimal configuration // in this case we must define best default properties for each dialect // The place where put default properties values is the Dialect itself. - IFluentSessionFactoryConfiguration sfc = null; - sfc + var cfg = new Configuration(); + cfg.SessionFactory() .Proxy.Through<ProxyFactoryFactory>() .Integrate .Using<MsSql2005Dialect>() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 20:57:51
|
Revision: 4548 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4548&view=rev Author: RicBrown Date: 2009-06-29 20:56:51 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added handling of multiple ICriterion in a single expression. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.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-06-29 20:20:14 UTC (rev 4547) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-06-29 20:56:51 UTC (rev 4548) @@ -278,12 +278,46 @@ return criterion; } + private static ICriterion ProcessAndExpression(BinaryExpression expression) + { + return + NHibernate.Criterion.Restrictions.And( + ProcessExpression(expression.Left), + ProcessExpression(expression.Right)); + } + + private static ICriterion ProcessOrExpression(BinaryExpression expression) + { + return + NHibernate.Criterion.Restrictions.Or( + ProcessExpression(expression.Left), + ProcessExpression(expression.Right)); + } + private static ICriterion ProcessBinaryExpression(BinaryExpression expression) { - if (IsMemberExpression(expression.Right)) - return ProcessMemberExpression(expression); - else - return ProcessSimpleExpression(expression); + switch (expression.NodeType) + { + case ExpressionType.AndAlso: + return ProcessAndExpression(expression); + + case ExpressionType.OrElse: + return ProcessOrExpression(expression); + + case ExpressionType.Equal: + case ExpressionType.NotEqual: + case ExpressionType.GreaterThan: + case ExpressionType.GreaterThanOrEqual: + case ExpressionType.LessThan: + case ExpressionType.LessThanOrEqual: + if (IsMemberExpression(expression.Right)) + return ProcessMemberExpression(expression); + else + return ProcessSimpleExpression(expression); + + default: + throw new Exception("Unhandled binary expression: " + expression.NodeType + ", " + expression.ToString()); + } } private static ICriterion ProcessBooleanExpression(Expression expression) @@ -306,16 +340,19 @@ throw new Exception("Could not determine member type from " + expression.ToString()); } - private static ICriterion ProcessLambdaExpression(LambdaExpression expression) + private static ICriterion ProcessExpression(Expression expression) { - var body = expression.Body; - - if (body is BinaryExpression) - return ProcessBinaryExpression((BinaryExpression)body); + if (expression is BinaryExpression) + return ProcessBinaryExpression((BinaryExpression)expression); else - return ProcessBooleanExpression((Expression)body); + return ProcessBooleanExpression((Expression)expression); } + private static ICriterion ProcessLambdaExpression(LambdaExpression expression) + { + return ProcessExpression(expression.Body); + } + /// <summary> /// Convert a lambda expression to NHibernate ICriterion /// </summary> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:20:14 UTC (rev 4547) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:56:51 UTC (rev 4548) @@ -64,6 +64,24 @@ } [Test] + public void MultipleCriterionExpression() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.And( + Restrictions.Eq("Name", "test name"), + Restrictions.Or( + Restrictions.Gt("Age", 21), + Restrictions.Eq("HasCar", true)))); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test name" && (p.Age > 21 || p.HasCar)); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] public void Where_BehavesTheSameAs_And() { Person personAlias = null; Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-29 20:20:14 UTC (rev 4547) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-29 20:56:51 UTC (rev 4548) @@ -11,6 +11,7 @@ public virtual string Name { get; set; } public virtual int Age { get; set; } public virtual int Height { get; set; } + public virtual bool HasCar { get; set; } public virtual Person Father { get; set; } public virtual IEnumerable<Child> Children { get; set; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 20:20:16
|
Revision: 4547 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4547&view=rev Author: RicBrown Date: 2009-06-29 20:20:14 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added coverage for property equality. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:12:51 UTC (rev 4546) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:20:14 UTC (rev 4547) @@ -40,6 +40,30 @@ } [Test] + public void PropertyCriterion_NoAlias() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.EqProperty("Age", "Height")) + .Add(Restrictions.NotEqProperty("Age", "Height")) + .Add(Restrictions.GtProperty("Age", "Height")) + .Add(Restrictions.GeProperty("Age", "Height")) + .Add(Restrictions.LtProperty("Age", "Height")) + .Add(Restrictions.LeProperty("Age", "Height")); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .And(p => p.Age == p.Height) + .And(p => p.Age != p.Height) + .And(p => p.Age > p.Height) + .And(p => p.Age >= p.Height) + .And(p => p.Age < p.Height) + .And(p => p.Age <= p.Height); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] public void Where_BehavesTheSameAs_And() { Person personAlias = null; Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-29 20:12:51 UTC (rev 4546) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-29 20:20:14 UTC (rev 4547) @@ -10,6 +10,7 @@ public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual int Age { get; set; } + public virtual int Height { get; set; } public virtual Person Father { get; set; } public virtual IEnumerable<Child> Children { get; set; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 20:12:52
|
Revision: 4546 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4546&view=rev Author: RicBrown Date: 2009-06-29 20:12:51 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added tests for simple criterion operators. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 19:46:11 UTC (rev 4545) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 20:12:51 UTC (rev 4546) @@ -20,11 +20,21 @@ { ICriteria expected = CreateTestCriteria(typeof(Person)) - .Add(Restrictions.Eq("Name", "test name")); + .Add(Restrictions.Eq("Name", "test name")) + .Add(Restrictions.Not(Restrictions.Eq("Name", "not test name"))) + .Add(Restrictions.Gt("Age", 10)) + .Add(Restrictions.Ge("Age", 11)) + .Add(Restrictions.Lt("Age", 50)) + .Add(Restrictions.Le("Age", 49)); ICriteria<Person> actual = CreateTestQueryOver<Person>() - .And(p => p.Name == "test name"); + .And(p => p.Name == "test name") + .And(p => p.Name != "not test name") + .And(p => p.Age > 10) + .And(p => p.Age >= 11) + .And(p => p.Age < 50) + .And(p => p.Age <= 49); 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-06-29 19:46:12
|
Revision: 4545 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4545&view=rev Author: RicBrown Date: 2009-06-29 19:46:11 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added integration test for DetachedCriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:38:33 UTC (rev 4544) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:46:11 UTC (rev 4545) @@ -27,6 +27,14 @@ _criteria = detachedCriteria; } + /// <summary> + /// Get an executable instance of <c>Criteria<T></c>, + /// to actually run the query.</summary> + public ICriteria<T> GetExecutableCriteria(ISession session) + { + return new CriteriaImpl<T>(_criteria.GetExecutableCriteria(session)); + } + public DetachedCriteria<T> And(Expression<Func<T, bool>> expression) { return Add(expression); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 19:38:33 UTC (rev 4544) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 19:46:11 UTC (rev 4545) @@ -67,6 +67,30 @@ } } + [Test] + public void DetachedCriteriaOfT_SimpleCriterion() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1", Age = 20 }); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + var personQuery = + DetachedCriteria.QueryOver<Person>() + .Where(p => p.Name == "test person 1"); + + IList<Person> actual = + personQuery.GetExecutableCriteria(s) + .List(); + + Assert.That(actual[0].Age, Is.EqualTo(20)); + } + } + } } \ 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-06-29 19:38:36
|
Revision: 4544 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4544&view=rev Author: RicBrown Date: 2009-06-29 19:38:33 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added first cut of DetachedCriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2009-06-29 18:52:24 UTC (rev 4543) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2009-06-29 19:38:33 UTC (rev 4544) @@ -95,6 +95,11 @@ return new DetachedCriteria(entityName, alias); } + public static DetachedCriteria<T> QueryOver<T>() + { + return new DetachedCriteria<T>(new DetachedCriteria(typeof(T))); + } + public DetachedCriteria Add(ICriterion criterion) { criteria.Add(criterion); Added: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:38:33 UTC (rev 4544) @@ -0,0 +1,53 @@ + +using System; +using System.Linq.Expressions; + +using NHibernate.Impl; + +namespace NHibernate.Criterion +{ + + /// <summary> + /// Some applications need to create criteria queries in "detached + /// mode", where the Hibernate session is not available. This class + /// may be instantiated anywhere, and then a <c>ICriteria</c> + /// may be obtained by passing a session to + /// <c>GetExecutableCriteria()</c>. All methods have the + /// same semantics and behavior as the corresponding methods of the + /// <c>ICriteria<T></c> interface. + /// </summary> + [Serializable] + public class DetachedCriteria<T> + { + + private DetachedCriteria _criteria; + + protected internal DetachedCriteria(DetachedCriteria detachedCriteria) + { + _criteria = detachedCriteria; + } + + public DetachedCriteria<T> And(Expression<Func<T, bool>> expression) + { + return Add(expression); + } + + public DetachedCriteria<T> Where(Expression<Func<T, bool>> expression) + { + return Add(expression); + } + + private DetachedCriteria<T> Add(Expression<Func<T, bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); + return this; + } + + public static implicit operator DetachedCriteria(DetachedCriteria<T> detachedCriteria) + { + return detachedCriteria._criteria; + } + + } + +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-29 18:52:24 UTC (rev 4543) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-29 19:38:33 UTC (rev 4544) @@ -477,6 +477,7 @@ <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> + <Compile Include="Criterion\DetachedCriteriaOfT.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/DetachedCriteriaOfTFixture.cs 2009-06-29 19:38:33 UTC (rev 4544) @@ -0,0 +1,48 @@ +using System; +using System.Collections; + +using NUnit.Framework; + +using NHibernate.Criterion; +using NHibernate.Transform; +using NHibernate.Type; +using NHibernate.Util; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class DetachedCriteriaOfTFixture : LambdaFixtureBase + { + + [Test] + public void SimpleCriterion_NoAlias() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .Add(Restrictions.Eq("Name", "test name")); + + DetachedCriteria<Person> actual = + DetachedCriteria.QueryOver<Person>() + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void Where_BehavesTheSameAs_And() + { + DetachedCriteria<Person> expected = + DetachedCriteria.QueryOver<Person>() + .And(p => p.Name == "test name"); + + DetachedCriteria<Person> actual = + DetachedCriteria.QueryOver<Person>() + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + } + +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-29 18:52:24 UTC (rev 4543) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-29 19:38:33 UTC (rev 4544) @@ -146,6 +146,7 @@ <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> + <Compile Include="Criteria\Lambda\DetachedCriteriaOfTFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-29 18:52:41
|
Revision: 4543 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4543&view=rev Author: RicBrown Date: 2009-06-29 18:52:24 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added first cut of Join() to ICriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-29 18:10:53 UTC (rev 4542) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-29 18:52:24 UTC (rev 4543) @@ -53,23 +53,31 @@ /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> - /// <param name="expression">Lambda expression returning association path</param> + /// <param name="path">Lambda expression returning association path</param> /// <returns>The created "sub criteria"</returns> - ICriteria<U> Join<U>(Expression<Func<T, U>> expression); + ICriteria<U> JoinWalk<U>(Expression<Func<T, U>> path); /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// specifying a collection for the join. /// </summary> /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> - /// <param name="expression">Lambda expression returning association path</param> + /// <param name="path">Lambda expression returning association path</param> /// <returns>The created "sub criteria"</returns> - ICriteria<U> Join<U>(Expression<Func<T, IEnumerable<U>>> expression); + ICriteria<U> JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path); /// <summary> + /// Join an association, assigning an alias to the joined entity + /// </summary> + /// <param name="path">Lambda expression returning association path</param> + /// <param name="alias">Lambda expression returning alias reference</param> + /// <returns>criteria instance</returns> + ICriteria<T> Join(Expression<Func<T, object>> path, Expression<Func<object>> alias); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> - /// <param name="results">The list filled with the results.</param> + /// <returns>The list filled with the results.</returns> IList<T> List(); } Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-29 18:10:53 UTC (rev 4542) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-29 18:52:24 UTC (rev 4543) @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; +using NHibernate.SqlCommand; namespace NHibernate.Impl { @@ -45,25 +46,39 @@ return Add(expression); } - ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, U>> expression) + ICriteria<U> ICriteria<T>.JoinWalk<U>(Expression<Func<T, U>> path) { return new CriteriaImpl<U>( _criteria.CreateCriteria( - ExpressionProcessor.FindMemberExpression(expression.Body))); + ExpressionProcessor.FindMemberExpression(path.Body))); } - ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, IEnumerable<U>>> expression) + ICriteria<U> ICriteria<T>.JoinWalk<U>(Expression<Func<T, IEnumerable<U>>> path) { return new CriteriaImpl<U>( _criteria.CreateCriteria( - ExpressionProcessor.FindMemberExpression(expression.Body))); + ExpressionProcessor.FindMemberExpression(path.Body))); } + ICriteria<T> ICriteria<T>.Join(Expression<Func<T, object>> path, Expression<Func<object>> alias) + { + return AddAlias( + ExpressionProcessor.FindMemberExpression(path.Body), + ExpressionProcessor.FindMemberExpression(alias.Body), + JoinType.InnerJoin); + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); } + private CriteriaImpl<T> AddAlias(string path, string alias, JoinType joinType) + { + _criteria.CreateAlias(path, alias, joinType); + return this; + } + private CriteriaImpl<T> Add(Expression<Func<T, bool>> expression) { _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 18:10:53 UTC (rev 4542) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-29 18:52:24 UTC (rev 4543) @@ -62,7 +62,7 @@ } [Test] - public void SubCriteria_Join_ToOne() + public void SubCriteria_JoinWalk_ToOne() { ICriteria expected = CreateTestCriteria(typeof(Person)) @@ -71,14 +71,14 @@ ICriteria<Person> actual = CreateTestQueryOver<Person>() - .Join(p => p.Father) // sub-criteria + .JoinWalk(p => p.Father) // sub-criteria .Where(f => f.Name == "test name"); AssertCriteriaAreEqual(expected, actual); } [Test] - public void SubCriteria_Join_ToMany() + public void SubCriteria_JoinWalk_ToMany() { ICriteria expected = CreateTestCriteria(typeof(Person)) @@ -87,12 +87,30 @@ ICriteria<Child> actual = CreateTestQueryOver<Person>() - .Join<Child>(p => p.Children) // sub-criteria + .JoinWalk<Child>(p => p.Children) // sub-criteria .Where(c => c.Nickname == "test name"); AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Alias_Join() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .CreateAlias("Children", "childAlias"); + + Person fatherAlias = null; + Child childAlias = null; + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Join(p => p.Father, () => fatherAlias) + .Join(p => p.Children, () => childAlias); + + 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-06-29 18:11:02
|
Revision: 4542 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4542&view=rev Author: RicBrown Date: 2009-06-29 18:10:53 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Reverted changes to ICriteria to keep ICriteria<T> separate (for now at least). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteria.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq.Expressions; using NHibernate.Criterion; using NHibernate.SqlCommand; using NHibernate.Transform; @@ -10,7 +9,7 @@ { /// <summary> /// Criteria is a simplified API for retrieving entities by composing - /// <see cref="Criterion.Expression" /> objects. + /// <see cref="Expression" /> objects. /// </summary> /// <remarks> /// <para> @@ -19,7 +18,7 @@ /// </para> /// <para> /// The Session is a factory for ICriteria. Expression instances are usually obtained via - /// the factory methods on <see cref="Criterion.Expression" />. eg: + /// the factory methods on <see cref="Expression" />. eg: /// </para> /// <code> /// IList cats = session.CreateCriteria(typeof(Cat)) @@ -83,14 +82,6 @@ ICriteria Add(ICriterion expression); /// <summary> - /// Add criterion expressed as a lambda expression - /// </summary> - /// <typeparam name="T">Type (same as criteria type)</typeparam> - /// <param name="expression">Lambda expression</param> - /// <returns>criteria instance</returns> - ICriteria Add<T>(Expression<Func<T, bool>> expression); - - /// <summary> /// An an Order to the result set /// </summary> /// <param name="order"></param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq.Expressions; using System.Text; using NHibernate.Criterion; using NHibernate.Engine; @@ -232,11 +231,6 @@ return this; } - public ICriteria Add<T>(Expression<Func<T, bool>> expression) - { - return Add(ExpressionProcessor.ProcessExpression<T>(expression)); - } - public IList List() { ArrayList results = new ArrayList(); @@ -673,11 +667,6 @@ return this; } - public ICriteria Add<T>(Expression<Func<T, bool>> expression) - { - return Add(ExpressionProcessor.ProcessExpression<T>(expression)); - } - public ICriteria AddOrder(Order order) { root.orderEntries.Add(new OrderEntry(order, this)); Deleted: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -1,34 +0,0 @@ -using System; -using System.Collections; - -using NUnit.Framework; - -using NHibernate.Criterion; -using NHibernate.Transform; -using NHibernate.Type; -using NHibernate.Util; - -namespace NHibernate.Test.Criteria.Lambda -{ - - [TestFixture] - public class CriteriaFixture : LambdaFixtureBase - { - - [Test] - public void Equality() - { - ICriteria expected = - CreateTestCriteria(typeof(Person)) - .Add(Restrictions.Eq("Name", "test name")); - - ICriteria actual = - CreateTestCriteria(typeof(Person)) - .Add<Person>(p => p.Name == "test name"); - - AssertCriteriaAreEqual(expected, actual); - } - - } - -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 18:10:53 UTC (rev 4542) @@ -43,30 +43,6 @@ } [Test] - public void ICriteria_SimpleCriterion() - { - using (ISession s = OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - s.Save(new Person() { Name = "test person 1" }); - s.Save(new Person() { Name = "test person 2" }); - s.Save(new Person() { Name = "test person 3" }); - - t.Commit(); - } - - using (ISession s = OpenSession()) - { - IList<Person> actual = - s.CreateCriteria(typeof(Person)) - .Add<Person>(p => p.Name == "test person 2") - .List<Person>(); - - Assert.That(actual.Count, Is.EqualTo(1)); - } - } - - [Test] public void ICriteriaOfT_SimpleCriterion() { using (ISession s = OpenSession()) Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-28 21:59:29 UTC (rev 4541) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-29 18:10:53 UTC (rev 4542) @@ -145,7 +145,6 @@ <Compile Include="Criteria\DetachedCriteriaSerializable.cs" /> <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> - <Compile Include="Criteria\Lambda\CriteriaFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-28 21:59:30
|
Revision: 4541 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4541&view=rev Author: RicBrown Date: 2009-06-28 21:59:29 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Added creation of sub-criteria to ICriteria<T>. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -12,10 +12,10 @@ /// </summary> /// <remarks> /// <code> - /// IList<Cat> cats = session.QueryOver<Cat>() - /// .Add( c => c.Name == "Tigger" ) - /// .Add( c => c.Weight > minWeight ) ) - /// .List(); + /// IList<Cat> cats = session.QueryOver<Cat>() + /// .Add( c => c.Name == "Tigger" ) + /// .Add( c => c.Weight > minWeight ) ) + /// .List(); /// </code> /// </remarks> public interface ICriteria<T> @@ -50,6 +50,23 @@ ICriteria<T> Where(Expression<Func<bool>> expression); /// <summary> + /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity + /// </summary> + /// <typeparam name="U">Type of sub-criteria</typeparam> + /// <param name="expression">Lambda expression returning association path</param> + /// <returns>The created "sub criteria"</returns> + ICriteria<U> Join<U>(Expression<Func<T, U>> expression); + + /// <summary> + /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity + /// specifying a collection for the join. + /// </summary> + /// <typeparam name="U">Type of sub-criteria (type of the collection)</typeparam> + /// <param name="expression">Lambda expression returning association path</param> + /// <returns>The created "sub criteria"</returns> + ICriteria<U> Join<U>(Expression<Func<T, IEnumerable<U>>> expression); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> /// <param name="results">The list filled with the results.</param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -45,6 +45,20 @@ return Add(expression); } + ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, U>> expression) + { + return new CriteriaImpl<U>( + _criteria.CreateCriteria( + ExpressionProcessor.FindMemberExpression(expression.Body))); + } + + ICriteria<U> ICriteria<T>.Join<U>(Expression<Func<T, IEnumerable<U>>> expression) + { + return new CriteriaImpl<U>( + _criteria.CreateCriteria( + ExpressionProcessor.FindMemberExpression(expression.Body))); + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -61,6 +61,38 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void SubCriteria_Join_ToOne() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateCriteria("Father") + .Add(Expression.Eq("Name", "test name")); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Join(p => p.Father) // sub-criteria + .Where(f => f.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void SubCriteria_Join_ToMany() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateCriteria("Children") + .Add(Expression.Eq("Nickname", "test name")); + + ICriteria<Child> actual = + CreateTestQueryOver<Person>() + .Join<Child>(p => p.Children) // sub-criteria + .Where(c => c.Nickname == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-28 13:57:21 UTC (rev 4540) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-28 21:59:29 UTC (rev 4541) @@ -7,14 +7,18 @@ public class Person { - public virtual int Id { get; set; } - public virtual string Name { get; set; } - public virtual int Age { get; set; } + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual int Age { get; set; } + public virtual Person Father { get; set; } + + public virtual IEnumerable<Child> Children { get; set; } } public class Child { - public virtual int Id { get; set; } + public virtual int Id { get; set; } + public virtual string Nickname { get; set; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-06-28 14:56:23
|
Revision: 4540 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4540&view=rev Author: ayenderahien Date: 2009-06-28 13:57:21 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Merging from 2.1.x - rest of commit More fixes for NH 1850 Will now also report timing for batched statements execution Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Property Changed: ---------------- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/ Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -397,7 +397,7 @@ InvalidateBatchCommand(); try { - DoExecuteBatch(ps); + ExecuteBatchWithTiming(ps); } finally { @@ -406,12 +406,27 @@ } } + protected void ExecuteBatchWithTiming(IDbCommand ps) + { + Stopwatch duration = null; + if (log.IsDebugEnabled) + duration = Stopwatch.StartNew(); + var countBeforeExecutingBatch = CountOfStatementsInCurrentBatch; + DoExecuteBatch(ps); + if (log.IsDebugEnabled && duration != null) + log.DebugFormat("ExecuteBatch for {0} statements took {1} ms", + countBeforeExecutingBatch, + duration.ElapsedMilliseconds); + } + /// <summary> /// /// </summary> /// <param name="ps"></param> protected abstract void DoExecuteBatch(IDbCommand ps); + protected abstract int CountOfStatementsInCurrentBatch { get; } + /// <summary> /// Gets or sets the size of the batch, this can change dynamically by /// calling the session's SetBatchSize. Modified: trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -9,7 +9,7 @@ /// An implementation of the <see cref="IBatcher" /> /// interface that does no batching. /// </summary> - internal class NonBatchingBatcher : AbstractBatcher + public class NonBatchingBatcher : AbstractBatcher { /// <summary> /// Initializes a new instance of the <see cref="NonBatchingBatcher"/> class. @@ -50,7 +50,12 @@ { } + protected override int CountOfStatementsInCurrentBatch + { + get { return 1; } + } + public override int BatchSize { get { return 1; } Modified: trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -72,7 +72,7 @@ if (countOfCommands >= batchSize) { - DoExecuteBatch(currentBatch); + ExecuteBatchWithTiming(currentBatch); } } @@ -108,6 +108,11 @@ } } + protected override int CountOfStatementsInCurrentBatch + { + get { return countOfCommands; } + } + private void SetObjectParam(Object obj, string paramName, object paramValue) { System.Type objType = obj.GetType(); Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 13:56:34 UTC (rev 4539) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 13:57:21 UTC (rev 4540) @@ -4,10 +4,12 @@ namespace NHibernate.AdoNet { + using System; + /// <summary> /// Summary description for SqlClientBatchingBatcher. /// </summary> - internal class SqlClientBatchingBatcher : AbstractBatcher + public class SqlClientBatchingBatcher : AbstractBatcher { private int batchSize; private int totalExpectedRowsAffected; @@ -32,6 +34,11 @@ set { batchSize = value; } } + protected override int CountOfStatementsInCurrentBatch + { + get { return currentBatch.CountOfCommands; } + } + public override void AddToBatch(IExpectation expectation) { totalExpectedRowsAffected += expectation.ExpectedRowCount; @@ -39,7 +46,7 @@ string lineWithParameters = null; var sqlStatementLogger = Factory.Settings.SqlStatementLogger; - if (sqlStatementLogger.IsDebugEnabled) + if (sqlStatementLogger.IsDebugEnabled || log.IsDebugEnabled) { lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate); var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic); @@ -57,13 +64,13 @@ if (currentBatch.CountOfCommands >= batchSize) { - DoExecuteBatch(batchUpdate); + ExecuteBatchWithTiming(batchUpdate); } } protected override void DoExecuteBatch(IDbCommand ps) { - log.Debug("Executing batch"); + log.DebugFormat("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests ___________________________________________________________________ Modified: svn:mergeinfo - /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513 + /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513,4537-4538 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-06-28 14:54:20
|
Revision: 4539 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4539&view=rev Author: ayenderahien Date: 2009-06-28 13:56:34 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Merging from 2.1.x - partial commit More fixes for NH 1850 Will now also report timing for batched statements execution Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs 2009-06-28 12:19:32 UTC (rev 4538) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs 2009-06-28 13:56:34 UTC (rev 4539) @@ -1,16 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NHibernate.Criterion; -using NUnit.Framework; +using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1850 { + using System; using AdoNet; + using Environment=NHibernate.Cfg.Environment; [TestFixture] public class Fixture:BugTestCase { + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + configuration.SetProperty(Environment.BatchSize, "1"); + } + [Test] public void CanGetQueryDurationForDelete() { @@ -30,6 +33,38 @@ } [Test] + public void CanGetQueryDurationForBatch() + { + using (LogSpy spy = new LogSpy(typeof(AbstractBatcher))) + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + for (int i = 0; i < 3; i++) + { + var customer = new Customer + { + Name = "foo" + }; + session.Save(customer); + session.Delete(customer); + } + session.Flush(); + + var wholeLog = spy.GetWholeLog(); + var lines = wholeLog.Split(new[]{System.Environment.NewLine},StringSplitOptions.RemoveEmptyEntries); + int batches = 0; + foreach (var line in lines) + { + if (line.Contains("ExecuteBatch for 1 statements took ")) + batches += 1; + } + Assert.AreEqual(3, batches); + + tx.Rollback(); + } + } + + [Test] public void CanGetQueryDurationForSelect() { using (LogSpy spy = new LogSpy(typeof(AbstractBatcher))) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-06-28 13:22:26
|
Revision: 4538 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4538&view=rev Author: ayenderahien Date: 2009-06-28 12:19:32 +0000 (Sun, 28 Jun 2009) Log Message: ----------- More fixes for NH 1850 Will now also report timing for batched statements execution Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs branches/2.1.x/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs branches/2.1.x/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-27 14:50:53 UTC (rev 4537) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-06-28 12:19:32 UTC (rev 4538) @@ -397,7 +397,7 @@ InvalidateBatchCommand(); try { - DoExecuteBatch(ps); + ExecuteBatchWithTiming(ps); } finally { @@ -406,12 +406,27 @@ } } + protected void ExecuteBatchWithTiming(IDbCommand ps) + { + Stopwatch duration = null; + if (log.IsDebugEnabled) + duration = Stopwatch.StartNew(); + var countBeforeExecutingBatch = CountOfStatementsInCurrentBatch; + DoExecuteBatch(ps); + if (log.IsDebugEnabled && duration != null) + log.DebugFormat("ExecuteBatch for {0} statements took {1} ms", + countBeforeExecutingBatch, + duration.ElapsedMilliseconds); + } + /// <summary> /// /// </summary> /// <param name="ps"></param> protected abstract void DoExecuteBatch(IDbCommand ps); + protected abstract int CountOfStatementsInCurrentBatch { get; } + /// <summary> /// Gets or sets the size of the batch, this can change dynamically by /// calling the session's SetBatchSize. Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-27 14:50:53 UTC (rev 4537) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/NonBatchingBatcher.cs 2009-06-28 12:19:32 UTC (rev 4538) @@ -9,7 +9,7 @@ /// An implementation of the <see cref="IBatcher" /> /// interface that does no batching. /// </summary> - internal class NonBatchingBatcher : AbstractBatcher + public class NonBatchingBatcher : AbstractBatcher { /// <summary> /// Initializes a new instance of the <see cref="NonBatchingBatcher"/> class. @@ -50,7 +50,12 @@ { } + protected override int CountOfStatementsInCurrentBatch + { + get { return 1; } + } + public override int BatchSize { get { return 1; } Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-27 14:50:53 UTC (rev 4537) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2009-06-28 12:19:32 UTC (rev 4538) @@ -72,7 +72,7 @@ if (countOfCommands >= batchSize) { - DoExecuteBatch(currentBatch); + ExecuteBatchWithTiming(currentBatch); } } @@ -108,6 +108,11 @@ } } + protected override int CountOfStatementsInCurrentBatch + { + get { return countOfCommands; } + } + private void SetObjectParam(Object obj, string paramName, object paramValue) { System.Type objType = obj.GetType(); Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-27 14:50:53 UTC (rev 4537) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-06-28 12:19:32 UTC (rev 4538) @@ -4,10 +4,12 @@ namespace NHibernate.AdoNet { + using System; + /// <summary> /// Summary description for SqlClientBatchingBatcher. /// </summary> - internal class SqlClientBatchingBatcher : AbstractBatcher + public class SqlClientBatchingBatcher : AbstractBatcher { private int batchSize; private int totalExpectedRowsAffected; @@ -32,6 +34,11 @@ set { batchSize = value; } } + protected override int CountOfStatementsInCurrentBatch + { + get { return currentBatch.CountOfCommands; } + } + public override void AddToBatch(IExpectation expectation) { totalExpectedRowsAffected += expectation.ExpectedRowCount; @@ -39,7 +46,7 @@ string lineWithParameters = null; var sqlStatementLogger = Factory.Settings.SqlStatementLogger; - if (sqlStatementLogger.IsDebugEnabled) + if (sqlStatementLogger.IsDebugEnabled || log.IsDebugEnabled) { lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate); var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic); @@ -57,13 +64,13 @@ if (currentBatch.CountOfCommands >= batchSize) { - DoExecuteBatch(batchUpdate); + ExecuteBatchWithTiming(batchUpdate); } } protected override void DoExecuteBatch(IDbCommand ps) { - log.Debug("Executing batch"); + log.DebugFormat("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs 2009-06-27 14:50:53 UTC (rev 4537) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs 2009-06-28 12:19:32 UTC (rev 4538) @@ -1,16 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NHibernate.Criterion; -using NUnit.Framework; +using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1850 { + using System; using AdoNet; + using Environment=NHibernate.Cfg.Environment; [TestFixture] public class Fixture:BugTestCase { + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + configuration.SetProperty(Environment.BatchSize, "1"); + } + [Test] public void CanGetQueryDurationForDelete() { @@ -30,6 +33,38 @@ } [Test] + public void CanGetQueryDurationForBatch() + { + using (LogSpy spy = new LogSpy(typeof(AbstractBatcher))) + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + for (int i = 0; i < 3; i++) + { + var customer = new Customer + { + Name = "foo" + }; + session.Save(customer); + session.Delete(customer); + } + session.Flush(); + + var wholeLog = spy.GetWholeLog(); + var lines = wholeLog.Split(new[]{System.Environment.NewLine},StringSplitOptions.RemoveEmptyEntries); + int batches = 0; + foreach (var line in lines) + { + if (line.Contains("ExecuteBatch for 1 statements took ")) + batches += 1; + } + Assert.AreEqual(3, batches); + + tx.Rollback(); + } + } + + [Test] public void CanGetQueryDurationForSelect() { using (LogSpy spy = new LogSpy(typeof(AbstractBatcher))) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Noreen K. <nhi...@li...> - 2009-06-27 20:09:37
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TOP Products </title> <style> body,html,table,tr,td {font:12px/14px Arial;} productTitle {font-family: Arial; font-size:12px;line-height:15px; color: #1e518e; padding:5px 5px 5px 5px; text-align:center; font-weight:bold;} drophead {font-family: Arial; font-size:12px;line-height:15px; color: #333333; padding:5px 5px 5px 5px; text-align:center;} productText {font-family: Arial; font-size:12px;line-height:15px; color: #333333; padding:5px 5px 5px 5px; text-align:center;} productPrice {color: #842b37; font-weight:bold;} productImage {padding:3px;border:1px solid #cccccc; background-color:#ffffff; margin-bottom:8px; margin-top:8px;} </style> </head> <body><div align="center" style="font:10px Verdana, Arial, Helvetica, sans-serif #000000; font-style:italic;">Having trouble viewing this email? <A TARGET="_blank" HREF="http://cy.tluksumov.cn/?ufj=FEC9E936ABBB8041EFBF">Click here</A> to see the online version.<br /> <br /> </div> <CopyRight></CopyRight> <OpenTracking/> <table width="600" cellpadding="0" cellspacing="0" align="center" style="border:2px solid #1e518e;"> <tr> <td width="600"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="center" width="100%" > <br /> <br /> <br /> <A TARGET="_blank" HREF="http://sts.tluksumov.cn/?loq=FEC9E936ABBB8041EFBF"> <img height="337" width="561" src="http://sts.tluksumov.cn/b.jpg" style="border-width: 0px" alt="Enter here!" /></a><br /> <br /> <br /> <br /></td> </tr> <tr> <td> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr bgcolor="#1e518e"> <td bgcolor="#1e518e" style="font-family: Arial, Helvetica, sans-serif; text-decoration: none; color: #ffffff; font-weight: normal; font-size: 10px; text-align:center; padding:8px 0px 8px 0px;vertical-align:top;"> <span style="font-size: 14px;"> <b>Customer Care</b></span><br /> <a href="http://luj.tluksumov.cn/?qb=FEC9E936ABBB8041EFBF" style="text-decoration: none; color: #ffffff;">Customer Care Main </a>| <a href="http://sts.tluksumov.cn/?uyh=FEC9E936ABBB8041EFBF" style="text-decoration: none; color: #ffffff;">FAQs </a>| <a href="http://sts.tluksumov.cn/?tyu=FEC9E936ABBB8041EFBF" style="text-decoration: none; color: #ffffff;">Placing an Order </a>|<a href="http://sts.tluksumov.cn/?pu=FEC9E936ABBB8041EFBF" style="text-decoration: none; color: #ffffff;">Returns and Refunds </a> | <a href="http://sts.tluksumov.cn/?jib=FEC9E936ABBB8041EFBF" style="text-decoration: none; color: #ffffff;">Shipping Rates and Policies </a>| <a href="http://sts.tluksumov.cn/?ir=FEC9E936ABBB8041EFBF" style="text-decoration: none; color: #ffffff;">Phone Support </a></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <table width="600" align="center"> <tr> <td align="center" style="color: #000000; font-weight: normal; font-size: 11px; font-family: Arial, Helvetica, sans-serif; text-decoration: none; padding:2px 10px 0px 10px; text-align:center;"> Click <a href="http://sts.tluksumov.cn/?aud=FEC9E936ABBB8041EFBF">here</a> to update your email preferences.<br /> To unsubscribe, <a href="http://sts.tluksumov.cn/?edq=FEC9E936ABBB8041EFBF">click here</a><br /> (c) 2009 Iioafquvi Company</td> </tr> </table> </body></html> |
From: <fab...@us...> - 2009-06-27 14:50:59
|
Revision: 4537 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4537&view=rev Author: fabiomaulo Date: 2009-06-27 14:50:53 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Fixed TYPO Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,7 +3,7 @@ { public interface IBatcherConfiguration { - IBatcherConfiguration Trough<TBatcher>() where TBatcher : IBatcherFactory; + IBatcherConfiguration Through<TBatcher>() where TBatcher : IBatcherFactory; IDbIntegrationConfiguration Each(short batchSize); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,7 +3,7 @@ { public interface ICacheConfiguration { - ICacheConfiguration Trough<TProvider>() where TProvider : ICacheProvider; + ICacheConfiguration Through<TProvider>() where TProvider : ICacheProvider; ICacheConfiguration PrefixingRegionsWith(string regionPrefix); ICacheConfiguration UsingMinimalPuts(); IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,6 +3,6 @@ { public interface ICollectionFactoryConfiguration { - IFluentSessionFactoryConfiguration Trough<TCollecionsFactory>() where TCollecionsFactory : ICollectionTypeFactory; + IFluentSessionFactoryConfiguration Through<TCollecionsFactory>() where TCollecionsFactory : ICollectionTypeFactory; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -5,7 +5,7 @@ { ICommandsConfiguration Preparing(); ICommandsConfiguration WithTimeout(int seconds); - ICommandsConfiguration ConvertingExceptionsTrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; + ICommandsConfiguration ConvertingExceptionsThrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; ICommandsConfiguration AutoCommentingSql(); IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions); IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions(); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -7,8 +7,8 @@ { public interface IConnectionConfiguration { - IConnectionConfiguration Trough<TProvider>() where TProvider : IConnectionProvider; - IConnectionConfiguration Through<TDriver>() where TDriver : IDriver; + IConnectionConfiguration Through<TProvider>() where TProvider : IConnectionProvider; + IConnectionConfiguration By<TDriver>() where TDriver : IDriver; IConnectionConfiguration With(IsolationLevel level); IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode); IDbIntegrationConfiguration Using(string connectionString); Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -2,7 +2,7 @@ { public interface IMappingsConfiguration { - IMappingsConfiguration UsingDefaultSchema(string defaultSchemaName); IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName); + IFluentSessionFactoryConfiguration UsingDefaultSchema(string defaultSchemaName); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -4,6 +4,6 @@ public interface IProxyConfiguration { IProxyConfiguration DisableValidation(); - IFluentSessionFactoryConfiguration Trough<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; + IFluentSessionFactoryConfiguration Through<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -4,6 +4,6 @@ { public interface IQueryCacheConfiguration { - ICacheConfiguration Trough<TFactory>() where TFactory : IQueryCache; + ICacheConfiguration Through<TFactory>() where TFactory : IQueryCache; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -3,6 +3,6 @@ { public interface ITransactionConfiguration { - IDbIntegrationConfiguration Trough<TFactory>() where TFactory : ITransactionFactory; + IDbIntegrationConfiguration Through<TFactory>() where TFactory : ITransactionFactory; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-27 07:07:50 UTC (rev 4536) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-27 14:50:53 UTC (rev 4537) @@ -1,5 +1,4 @@ using System.Data; -using System.Data.Common; using System.Data.SqlClient; using NHibernate.AdoNet; using NHibernate.ByteCode.LinFu; @@ -21,21 +20,37 @@ // Using the Configuration class the user can add mappings and configure listeners IFluentSessionFactoryConfiguration sfc= null; sfc.Named("SomeName") + .Caching + .Through<HashtableCacheProvider>() + .PrefixingRegionsWith("xyz") + .Queries + .Through<StandardQueryCache>() + .UsingMinimalPuts() + .WithDefaultExpiration(15) + .GeneratingCollections + .Through<DefaultCollectionTypeFactory>() + .Proxy + .DisableValidation() + .Through<ProxyFactoryFactory>() + .ParsingHqlThrough<ClassicQueryTranslatorFactory>() + .Mapping + .UsingDefaultCatalog("MyCatalog") + .UsingDefaultSchema("MySche") .Integrate .Using<MsSql2000Dialect>() .AutoQuoteKeywords() .BatchingQueries - .Trough<SqlClientBatchingBatcherFactory>() + .Through<SqlClientBatchingBatcherFactory>() .Each(10) .Connected - .Trough<DebugConnectionProvider>() - .Through<SqlClientDriver>() + .Through<DebugConnectionProvider>() + .By<SqlClientDriver>() .Releasing(ConnectionReleaseMode.AfterTransaction) .With(IsolationLevel.ReadCommitted) .Using("The connection string but it has some overload") .CreateCommands .AutoCommentingSql() - .ConvertingExceptionsTrough<SQLStateConverter>() + .ConvertingExceptionsThrough<SQLStateConverter>() .Preparing() .WithTimeout(10) .WithMaximumDepthOfOuterJoinFetching(10) @@ -43,23 +58,7 @@ .Schema .Validating() ; - sfc.Caching - .Trough<HashtableCacheProvider>() - .PrefixingRegionsWith("xyz") - .Queries - .Trough<StandardQueryCache>() - .UsingMinimalPuts() - .WithDefaultExpiration(15) - .GeneratingCollections - .Trough<DefaultCollectionTypeFactory>() - .Proxy - .DisableValidation() - .Trough<ProxyFactoryFactory>() - .ParsingHqlThrough<ClassicQueryTranslatorFactory>() - .Mapping - .UsingDefaultCatalog("MyCatalog") - .UsingDefaultSchema("MySche") - ; + } public void ProofOfConceptMinimalConfiguration() @@ -69,7 +68,7 @@ // The place where put default properties values is the Dialect itself. IFluentSessionFactoryConfiguration sfc = null; sfc - .Proxy.Trough<ProxyFactoryFactory>() + .Proxy.Through<ProxyFactoryFactory>() .Integrate .Using<MsSql2005Dialect>() .Connected This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-27 07:07:51
|
Revision: 4536 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4536&view=rev Author: RicBrown Date: 2009-06-27 07:07:50 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Added overload for And() with same semantics as Where(). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 06:53:39 UTC (rev 4535) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 07:07:50 UTC (rev 4536) @@ -29,6 +29,13 @@ ICriteria<T> And(Expression<Func<T, bool>> expression); /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + ICriteria<T> And(Expression<Func<bool>> expression); + + /// <summary> /// Identical semantics to Add() to allow more readable queries /// </summary> /// <param name="expression">Lambda expression</param> @@ -36,7 +43,7 @@ ICriteria<T> Where(Expression<Func<T, bool>> expression); /// <summary> - /// Add criterion expressed as a lambda expression + /// Identical semantics to Add() to allow more readable queries /// </summary> /// <param name="expression">Lambda expression</param> /// <returns>criteria instance</returns> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 06:53:39 UTC (rev 4535) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 07:07:50 UTC (rev 4536) @@ -27,20 +27,22 @@ ICriteria<T> ICriteria<T>.And(Expression<Func<T, bool>> expression) { - _criteria.Add(expression); - return this; + return Add(expression); } + ICriteria<T> ICriteria<T>.And(Expression<Func<bool>> expression) + { + return Add(expression); + } + ICriteria<T> ICriteria<T>.Where(Expression<Func<T, bool>> expression) { - _criteria.Add(expression); - return this; + return Add(expression); } ICriteria<T> ICriteria<T>.Where(Expression<Func<bool>> expression) { - _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); - return this; + return Add(expression); } IList<T> ICriteria<T>.List() @@ -48,6 +50,18 @@ return _criteria.List<T>(); } + private CriteriaImpl<T> Add(Expression<Func<T, bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression)); + return this; + } + + private CriteriaImpl<T> Add(Expression<Func<bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); + return this; + } + } } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 06:53:39 UTC (rev 4535) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 07:07:50 UTC (rev 4536) @@ -32,12 +32,15 @@ [Test] public void Where_BehavesTheSameAs_And() { + Person personAlias = null; Impl.CriteriaImpl<Person> expected = (Impl.CriteriaImpl<Person>) - CreateTestQueryOver<Person>() + CreateTestQueryOver<Person>(() => personAlias) + .And(() => personAlias.Name == "test name") .And(p => p.Name == "test name"); ICriteria<Person> actual = - CreateTestQueryOver<Person>() + CreateTestQueryOver<Person>(() => personAlias) + .Where(() => personAlias.Name == "test name") .Where(p => p.Name == "test name"); AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-27 06:53:42
|
Revision: 4535 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4535&view=rev Author: RicBrown Date: 2009-06-27 06:53:39 +0000 (Sat, 27 Jun 2009) Log Message: ----------- Added first cut of ICriteria<T> alias syntax using a reference variable. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -36,6 +36,13 @@ ICriteria<T> Where(Expression<Func<T, bool>> expression); /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + ICriteria<T> Where(Expression<Func<bool>> expression); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> /// <param name="results">The list filled with the results.</param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -37,6 +37,12 @@ return this; } + ICriteria<T> ICriteria<T>.Where(Expression<Func<bool>> expression) + { + _criteria.Add(ExpressionProcessor.ProcessExpression(expression)); + return this; + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -16,19 +16,48 @@ { [Test] - public void Equality() + public void SimpleCriterion_NoAlias() { ICriteria expected = CreateTestCriteria(typeof(Person)) .Add(Restrictions.Eq("Name", "test name")); ICriteria<Person> actual = - CreateTestCriteria<Person>() + CreateTestQueryOver<Person>() .And(p => p.Name == "test name"); AssertCriteriaAreEqual(expected, actual); } + [Test] + public void Where_BehavesTheSameAs_And() + { + Impl.CriteriaImpl<Person> expected = (Impl.CriteriaImpl<Person>) + CreateTestQueryOver<Person>() + .And(p => p.Name == "test name"); + + ICriteria<Person> actual = + CreateTestQueryOver<Person>() + .Where(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual); + } + + [Test] + public void SimpleCriterion_AliasReferenceSyntax() + { + ICriteria expected = + CreateTestCriteria(typeof(Person), "personAlias") + .Add(Restrictions.Eq("personAlias.Name", "test name")); + + Person personAlias = null; + ICriteria<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .Where(() => personAlias.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-26 14:20:18 UTC (rev 4534) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-27 06:53:39 UTC (rev 4535) @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq.Expressions; using System.Reflection; using NHibernate.Criterion; @@ -29,11 +30,17 @@ return new CriteriaImpl(persistentClass, alias, null); } - protected ICriteria<T> CreateTestCriteria<T>() + protected ICriteria<T> CreateTestQueryOver<T>() { return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), null)); } + protected ICriteria<T> CreateTestQueryOver<T>(Expression<Func<object>> alias) + { + string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body); + return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), aliasContainer, null)); + } + protected void AssertCriteriaAreEqual(ICriteria expected, ICriteria actual) { AssertObjectsAreEqual(expected, actual); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: bellicosity<det...@ze...> - 2009-06-26 19:41:15
|
Love Dollls: Can they Sumbstitute you a Real Lover? www. pill22. com. DtNA Tests Ordered for Urine Toolbox Prrank |
From: <fab...@us...> - 2009-06-26 14:20:25
|
Revision: 4534 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4534&view=rev Author: fabiomaulo Date: 2009-06-26 14:20:18 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Merge from r4533 (fix NH-1853) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-06-26 14:15:32 UTC (rev 4533) +++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-06-26 14:20:18 UTC (rev 4534) @@ -643,7 +643,24 @@ } } - // Not ported - addResource(String path) - not applicable + /// <summary> + /// Adds the mappings from ebedded resources of the assembly. + /// </summary> + /// <param name="paths">Paths to the resource files in the assembly.</param> + /// <param name="assembly">The assembly that contains the resource files.</param> + /// <returns>This configuration object.</returns> + public Configuration AddResources(IEnumerable<string> paths, Assembly assembly) + { + if (paths == null) + { + throw new ArgumentNullException("paths"); + } + foreach (var path in paths) + { + AddResource(path, assembly); + } + return this; + } /// <summary> /// Read a mapping from an embedded resource, using a convention. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |