Implements a read-only
Although this is advertised as immutable, it really isn't. Anyone with access to the - wrapped set can still change the set.
-Implements a thread-safe
- Abstracts ADO.NET batching to maintain the illusion that a single logical batch
- exists for the whole session, even when batching is disabled.
- Provides transparent
- This will be useful once ADO.NET gets support for batching. Until that point - no code exists that will do batching, but this will provide a good point to do - error checking and making sure the correct number of rows were affected. -
-
- configure.TypeDefinition<TableHiLoGenerator>(c=>
- {
- c.Alias = "HighLow";
- c.Properties = new {max_lo = 99};
- });
-
-
- configuration.Configure("path/to/hibernate.cfg.xml");
-
-
- If this ConnectionProvider is being Finalized (
- If any subclasses manage resources that also need to be disposed of this method - should be overridden, but don't forget to call it in the override. -
-SELECT clause SELECT clause (
- List results = session.CreateCriteria(typeof(Parent))
- .Add( Example.Create(parent).IgnoreCase() )
- .CreateCriteria("child")
- .Add( Example.Create( parent.Child ) )
- .List();
-
-
- IList<Cat> cats = session.QueryOver<Cat>()
- .Where( c => c.Name == "Tigger" )
- .And( c => c.Weight > minWeight ) )
- .List();
-
-
- IList<Cat> cats = session.QueryOver<Cat>()
- .Where( c => c.Name == "Tigger" )
- .And( c => c.Weight > minWeight ) )
- .List();
-
- concat(?1, ?2) to concatenate two strings
- p1 and p2. Target SQL function will be dialect-specific, e.g. (?1 || ?2) for
- Oracle, concat(?1, ?2) for MySql, (?1 + ?2) for MS SQL.
- Each dialect will define a template as a string (exactly like above) marking function
- parameters with '?' followed by parameter's index (first index is 1).
-
- This method assumes that the name is not already Quoted. So if the name passed
- in is
- If the aliasName is already enclosed in the OpenQuote and CloseQuote then this - method will return the aliasName that was passed in without going through any - Quoting process. So if aliasName is passed in already Quoted make sure that - you have escaped all of the chars according to your DataBase's specifications. -
-- If the columnName is already enclosed in the OpenQuote and CloseQuote then this - method will return the columnName that was passed in without going through any - Quoting process. So if columnName is passed in already Quoted make sure that - you have escaped all of the chars according to your DataBase's specifications. -
-- If the tableName is already enclosed in the OpenQuote and CloseQuote then this - method will return the tableName that was passed in without going through any - Quoting process. So if tableName is passed in already Quoted make sure that - you have escaped all of the chars according to your DataBase's specifications. -
-- If the schemaName is already enclosed in the OpenQuote and CloseQuote then this - method will return the schemaName that was passed in without going through any - Quoting process. So if schemaName is passed in already Quoted make sure that - you have escaped all of the chars according to your DataBase's specifications. -
-
- This method checks the string
- After the OpenQuote and CloseQuote have been cleaned from the string
- The following quoted values return these results - "quoted" = quoted - "quote""d" = quote"d - quote""d = quote"d -
-- If this implementation is not sufficient for your Dialect then it needs to be overridden. - MsSql2000Dialect is an example of where UnQuoting rules are different. -
-- Author: Ioan Bizau -
-- This dialect probably will not work with schema-export. If anyone out there - can fill in the ctor with DbTypes to Strings that would be helpful. -
- The dialect defaults the following configuration properties: -
- Names.Put(DbType, "TEXT" );
- Names.Put(DbType, 255, "VARCHAR($l)" );
- Names.Put(DbType, 65534, "LONGVARCHAR($l)" );
-
- will give you back the following:
-
- Names.Get(DbType) // --> "TEXT" (default)
- Names.Get(DbType,100) // --> "VARCHAR(100)" (100 is in [0:255])
- Names.Get(DbType,1000) // --> "LONGVARCHAR(1000)" (100 is in [256:65534])
- Names.Get(DbType,100000) // --> "TEXT" (default)
-
- On the other hand, simply putting
-
- Names.Put(DbType, "VARCHAR($l)" );
-
- would result in
-
- Names.Get(DbType) // --> "VARCHAR($l)" (will cause trouble)
- Names.Get(DbType,100) // --> "VARCHAR(100)"
- Names.Get(DbType,1000) // --> "VARCHAR(1000)"
- Names.Get(DbType,10000) // --> "VARCHAR(10000)"
-
- - Author: Nikolaos Tountas -
-- In order to use this Driver you must have the Community.CsharpSqlite.dll and Community.CsharpSqlite.SQLiteClient assemblies referenced. -
-- Please check http://code.google.com/p/csharp-sqlite/ for more information regarding csharp-sqlite. -
-
- key="connection.driver_class"
- value="FullyQualifiedClassName, AssemblyName"
-
- IDbParameter param = cmd.Parameters["@paramName"]
- if this is false the code will be
- IDbParameter param = cmd.Parameters["paramName"].
- - Author: Oliver Weichhold -
-- In order to use this Driver you must have the Npgsql.dll Assembly available for - NHibernate to load it. -
-- Please check the products website - http://www.postgresql.org/ - for any updates and or documentation. -
-- The homepage for the .NET DataProvider is: - http://pgfoundry.org/projects/npgsql. -
-- In order to use this driver you must have the System.Data.SQLite.dll assembly available - for NHibernate to load. This assembly includes the SQLite.dll or SQLite3.dll libraries. -
-- You can get the System.Data.SQLite.dll assembly from http://sourceforge.net/projects/sqlite-dotnet2. -
-- Please check http://www.sqlite.org/ for more information regarding SQLite. -
-
- using (ISession session = factory.OpenSession())
- using (ITransaction tx = session.BeginTransaction())
- {
- try
- {
- // do some work
- ...
- tx.Commit();
- }
- catch (Exception e)
- {
- if (tx != null) tx.Rollback();
- throw;
- }
- }
-
- | NAME | -DEFAULT | -DESCRIPTION | -
| The name of the sequence/table to use to store/retrieve values | -||
| The initial value to be stored for the given segment; the effect in terms of storage varies based on |
- ||
| The increment size for the underlying segment; the effect in terms of storage varies based on |
- ||
| depends on defined increment size | -Allows explicit definition of which optimization strategy to use | -|
| false | -Allows explicit definition of which optimization strategy to use | -
| NAME | -DEFAULT | -DESCRIPTION | -
| The name of column which holds the sequence value for the given segment | -
| NAME | -DEFAULT | -DESCRIPTION | -
| The name of the table to use to store/retrieve values | -||
| The name of column which holds the sequence value for the given segment | -||
| The name of the column which holds the segment key | -||
| The value indicating which segment is used by this generator; refers to values in the |
- ||
| The data length of the |
- ||
| The initial value to be stored for the given segment | -||
| The increment size for the underlying segment; see the discussion on |
- ||
| depends on defined increment size | -Allows explicit definition of which optimization strategy to use | -
- This id generation strategy is specified in the mapping file as
- <generator class="assigned" />
-
- <generator class="foreign">
- <param name="property">AssociatedObject</param>
- </generator>
-
-
- This id generation strategy is specified in the mapping file as
- <generator class="guid.comb" />
-
- The
- This code was contributed by Donald Mull. -
-
- This id generation strategy is specified in the mapping file as
- <generator class="guid" />
-
The built in strategies for identifier generation in NHibernate are:
-
- This id generation strategy is specified in the mapping file as
- <generator class="identity" />
- or if the database natively supports identity columns
- <generator class="native" />
-
- This indicates to NHibernate that the database generates the id when - the entity is inserted. -
-
- This id generation strategy is specified in the mapping file as
-
- <generator class="sequence">
- <param name="sequence">uid_sequence</param>
- <param name="schema">db_schema</param>
- </generator>
-
-
- The
- This id generation strategy is specified in the mapping file as
-
- <generator class="seqhilo">
- <param name="sequence">uid_sequence</param>
- <param name="max_lo">max_lo_value</param>
- <param name="schema">db_schema</param>
- </generator>
-
-
- The
- The user may specify a
- It is not intended that applications use this strategy directly. However,
- it may be used to build other (efficient) strategies. The return type is
-
- The hi value MUST be fetched in a separate transaction to the
- The mapping parameters
- This id generation strategy is specified in the mapping file as
-
- <generator class="hilo">
- <param name="table">table</param>
- <param name="column">id_column</param>
- <param name="max_lo">max_lo_value</param>
- <param name="schema">db_schema</param>
- </generator>
-
-
- The
- The hi value MUST be fecthed in a separate transaction to the
- This id generation strategy is specified in the mapping file as
-
- <generator class="uuid.hex">
- <param name="format">format_string</param>
- <param name="seperator">seperator_string</param>
- </generator>
-
-
- The
- The identifier string will consist of only hex digits. Optionally, the identifier string - may be generated with enclosing characters and seperators between each component - of the UUID. If there are seperators then the string length will be 36. If a format - that has enclosing brackets is used, then the string length will be 38. -
-
-
-
- This class is based on
- This id generation strategy is specified in the mapping file as
- <generator class="uuid.string" />
-
- SetParameter("foo", foo, NHibernateUtil.Int32);
-
- A name may appear multiple times in the query string.
- - Entities returned as results are initialized on demand. The first SQL query returns - identifiers only. -
-
- This is a good strategy to use if you expect a high number of the objects
- returned to be already loaded in the
- IList cats = session.CreateCriteria(typeof(Cat))
- .Add(Expression.Like("name", "Iz%"))
- .Add(Expression.Gt("weight", minWeight))
- .AddOrder(Order.Asc("age"))
- .List();
-
- You may navigate associations using
- IList<Cat> cats = session.CreateCriteria<Cat>
- .CreateCriteria("kittens")
- .Add(Expression.like("name", "Iz%"))
- .List<Cat>();
-
-
- IList<Cat> cats = session.CreateCriteria<Cat>
- .SetProjection(
- Projections.ProjectionList()
- .Add(Projections.RowCount())
- .Add(Projections.Avg("weight"))
- .Add(Projections.Max("weight"))
- .Add(Projections.Min("weight"))
- .Add(Projections.GroupProperty("color")))
- .AddOrder(Order.Asc("color"))
- .List<Cat>();
-
-
- <sql-query-name name="mySqlQuery">
- <return alias="person" class="eg.Person" />
- SELECT {person}.NAME AS {person.name}, {person}.AGE AS {person.age}, {person}.SEX AS {person.sex}
- FROM PERSON {person} WHERE {person}.NAME LIKE 'Hiber%'
- </sql-query-name>
-
- CAST(x AS INT) which does not work in MSSQLSERVER, and possibly
- other databases.
-
- from p in db.Products
- group p by p.Category.CategoryId
- into g
- select new
- {
- g.Key,
- MaxPrice = g.Max(p => p.UnitPrice)
- };
-
-
- This class implements useful common functionality that concrete loaders would delegate to.
- It is not intended that this functionality would be directly accessed by client code (Hence,
- all methods of this class are declared
- The present implementation is able to load any number of columns of entities and at most - one collection role per query. -
-
- If a value is passed in that is wrapped by
- The value returned by the getter is not Quoted. To get the
- column name in quoted form use
- If a value is passed in that is wrapped by
- The value returned by the getter is not Quoted. To get the
- column name in quoted form use
case when ... then ... end as ...
- decode(pkvalue, key1, 1, key2, 2, ..., 0)
-
- The
- The
- This can store the length of the binary data that the
- This is only needed by DataProviders (SqlClient) that need to specify a Size for the - IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a - BinarySqlType would work just fine. -
-
- This can store the length of the binary data that the
- This is only needed by DataProviders (SqlClient) that need to specify a Size for the - IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a - StringSqlType would work just fine. -
-
- IList resultWithAliasedBean = s.CreateCriteria(typeof(Enrollment))
- .CreateAlias("Student", "st")
- .CreateAlias("Course", "co")
- .SetProjection( Projections.ProjectionList()
- .Add( Projections.Property("co.Description"), "CourseDescription" )
- )
- .SetResultTransformer( new AliasToBeanResultTransformer(typeof(StudentDTO)) )
- .List();
-
- StudentDTO dto = (StudentDTO)resultWithAliasedBean[0];
-
- - The value stored in the database depends on what your data provider is capable - of storing. So there is a possibility that the DateTime you save will not be - the same DateTime you get back when you check DateTime.Equals(DateTime) because - they will have their milliseconds off. -
-
- For example - SQL Server 2000 is only accurate to 3.33 milliseconds. So if
- NHibernate writes a value of
- Please review the documentation of your Database server. -
-
- public enum MyEnum
- {
- On,
- Off,
- Dimmed
- }
-
-
-
- public class MyEnumStringType : NHibernate.Type.EnumStringType
- {
- public MyEnumStringType()
- : base( typeof( MyEnum ) )
- {
- }
- }
-
-
-
- ...
- <property name="Status" type="MyEnumStringType, AssemblyContaining" />
- ...
-
-
- 'T'/'F' to indicate true/false.
- 'Y'/'N' to indicate true/false.
- any.
-
- CREATE TABLE [dbo].[Log] (
- [ID] [int] IDENTITY (1, 1) NOT NULL ,
- [Date] [datetime] NOT NULL ,
- [Thread] [varchar] (255) NOT NULL ,
- [Level] [varchar] (20) NOT NULL ,
- [Logger] [varchar] (255) NOT NULL ,
- [Message] [varchar] (4000) NOT NULL
- ) ON [PRIMARY]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
- "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
- "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
- System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
- This is an optional package that you can download from
- http://msdn.microsoft.com/downloads
- search for ODBC .NET Data Provider.
- System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- This is an optional package that you can download from
- http://msdn.microsoft.com/downloads
- search for .NET Managed Provider for Oracle.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <mapping>
- <level value="ERROR" />
- <eventLogEntryType value="Error" />
- </mapping>
- <mapping>
- <level value="DEBUG" />
- <eventLogEntryType value="Information" />
- </mapping>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
- UdpClient udpClient;
- byte[] buffer;
- string loggingEvent;
-
- try
- {
- udpClient = new UdpClient(8080);
-
- while(true)
- {
- buffer = udpClient.Receive(ref remoteEndPoint);
- loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
- Console.WriteLine(loggingEvent);
- }
- }
- catch(Exception e)
- {
- Console.WriteLine(e.ToString());
- }
-
-
- Dim remoteEndPoint as IPEndPoint
- Dim udpClient as UdpClient
- Dim buffer as Byte()
- Dim loggingEvent as String
-
- Try
- remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
- udpClient = new UdpClient(8080)
-
- While True
- buffer = udpClient.Receive(ByRef remoteEndPoint)
- loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
- Console.WriteLine(loggingEvent)
- Wend
- Catch e As Exception
- Console.WriteLine(e.ToString())
- End Try
-
-
-
-
-
-
-
-
-
- using log4net.Config;
- using System.IO;
- using System.Configuration;
-
- ...
-
- DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
-
-
-
-
-
-
-
-
-
- using log4net.Config;
- using System.IO;
- using System.Configuration;
-
- ...
-
- DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- log4net configuration XML goes here
-
-
-
-
-
-
-
-
-
- using log4net.Config;
- using System.IO;
- using System.Configuration;
-
- ...
-
- XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- using log4net.Config;
- using System.IO;
- using System.Configuration;
-
- ...
-
- XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
-
-
-
-
-
-
-
-
-
- ILog log = LogManager.GetLogger("application-log");
-
- log.Info("Application Start");
- log.Debug("This is a debug message");
-
- if (log.IsDebugEnabled)
- {
- log.Debug("This is another debug message");
- }
-
-
- log.Debug("This is entry number: " + i );
-
-
- if (log.IsDebugEnabled)
- {
- log.Debug("This is entry number: " + i );
- }
-
-
- private static readonly bool isDebugEnabled = log.IsDebugEnabled;
-
-
- if (isDebugEnabled)
- {
- log.Debug("This is entry number: " + i );
- }
-
-
- log.Debug("This is entry number: " + i );
-
-
- if (log.IsDebugEnabled())
- {
- log.Debug("This is entry number: " + i );
- }
-
-
- {key1=value1, key2=value2, key3=value3}
-
-
- {key1=value1, key2=value2, key3=value3}
-
-
- ILog log = LogManager.GetLogger(typeof(TestApp));
- log.Debug("Message 1");
- log.Warn("Message 2");
-
-
- DEBUG [main]: Message 1
- WARN [main]: Message 2
-
- | Format modifier | -left justify | -minimum width | -maximum width | -comment | -
|---|---|---|---|---|
| %20logger | -false | -20 | -none | -
- |
-
| %-20logger | -true | -20 | -none | -
- |
-
| %.30logger | -NA | -none | -30 | -
- |
-
| false | -20 | -30 | -
- |
- |
| %-20.30logger | -true | -20 | -30 | -
- |
-
%timestamp [%thread] %level %logger %ndc - %message%newline
- %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
-
- StringWriter writer = new StringWriter();
- Layout.Format(writer, loggingEvent);
- string formattedEvent = writer.ToString();
-
-
- DEBUG - Hello world
-
-
- <?xml version="1.0" ?>
-
- <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
-
- <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
- &data;
- </log4net:events>
-
-
- using log4net.Util;
-
- ILog log = LogManager.GetLogger("application-log");
-
- log.InfoExt("Application Start");
- log.DebugExt("This is a debug message");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
-
-
- string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
-
-
- using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
- {
- log.Warn("This should have an ThreadContext Stack message");
- }
-
-
- GlobalContext.Properties["hostname"] = Environment.MachineName;
-
-
- LogicalThreadContext.Properties["user"] = userName;
- log.Info("This log message has a LogicalThreadContext Property called 'user'");
-
-
- using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
- {
- log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
-
- } // at the end of the using block the message is automatically popped
-
-
- ILog log = LogManager.GetLogger("application-log");
-
- log.Info("Application Start");
- log.Debug("This is a debug message");
-
- if (log.IsDebugEnabled)
- {
- log.Debug("This is another debug message");
- }
-
-
- using(NDC.Push("my context message"))
- {
- ... all log calls will have 'my context message' included ...
-
- } // at the end of the using block the message is automatically removed
-
-
- using(log4net.NDC.Push("NDC_Message"))
- {
- log.Warn("This should have an NDC message");
- }
-
-
- ThreadContext.Properties["user"] = userName;
- log.Info("This log message has a ThreadContext Property called 'user'");
-
-
- using(ThreadContext.Stacks["NDC"].Push("my context message"))
- {
- log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
-
- } // at the end of the using block the message is automatically popped
-
-