-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathMySqlDataDriver.cs
84 lines (73 loc) · 2.88 KB
/
MySqlDataDriver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using NHibernate.AdoNet;
namespace NHibernate.Driver
{
/// <summary>
/// Provides a database driver for MySQL.
/// </summary>
/// <remarks>
/// <para>
/// In order to use this driver you must have the assembly <c>MySql.Data.dll</c> available for
/// NHibernate to load, including its dependencies (<c>ICSharpCode.SharpZipLib.dll</c> is required by
/// the assembly <c>MySql.Data.dll</c> as of the time of this writing).
/// </para>
/// <para>
/// Please check the product's <see href="http://www.mysql.com/products/connector/net/">website</see>
/// for any updates and/or documentation regarding MySQL.
/// </para>
/// </remarks>
public class MySqlDataDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="MySqlDataDriver"/> class.
/// </summary>
/// <exception cref="HibernateException">
/// Thrown when the <c>MySql.Data</c> assembly can not be loaded.
/// </exception>
public MySqlDataDriver() : base(
"MySql.Data.MySqlClient",
"MySql.Data",
"MySql.Data.MySqlClient.MySqlConnection",
"MySql.Data.MySqlClient.MySqlCommand")
{
}
/// <summary>
/// MySql.Data uses named parameters in the sql.
/// </summary>
/// <value><see langword="true" /> - MySql uses <c>?</c> in the sql.</value>
public override bool UseNamedPrefixInSql => true;
/// <summary></summary>
public override bool UseNamedPrefixInParameter => true;
/// <summary>
/// MySql.Data use the <c>?</c> to locate parameters in sql.
/// </summary>
/// <value><c>?</c> is used to locate parameters in sql.</value>
public override string NamedPrefix => "?";
/// <summary>
/// The MySql.Data driver does NOT support more than 1 open DbDataReader
/// with only 1 DbConnection.
/// </summary>
/// <value><see langword="false" /> - it is not supported.</value>
public override bool SupportsMultipleOpenReaders => false;
/// <summary>
/// MySql.Data does not support preparing of commands.
/// </summary>
/// <value><see langword="false" /> - it is not supported.</value>
/// <remarks>
/// With the Gamma MySql.Data provider it is throwing an exception with the
/// message "Expected End of data packet" when a select command is prepared.
/// </remarks>
protected override bool SupportsPreparingCommands => false;
public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session)
{
return new BasicResultSetsCommand(session);
}
public override bool SupportsMultipleQueries => true;
public override bool RequiresTimeSpanForTime => true;
// As of v5.7, lower dates may "work" but without guarantees.
// https://dev.mysql.com/doc/refman/5.7/en/datetime.html
/// <inheritdoc />
public override DateTime MinDate => new DateTime(1000, 1, 1);
System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass => typeof(MySqlClientBatchingBatcherFactory);
}
}