My company is using nhibernate along with the CoreLab MyDirect MySQL ADO .net driver (we couldn't open source our app and the licensing fees on the Connector/Net ado driver are ridiculous) So i created a reflection based driver. Everything seems to work okay so i thought i'd post it in case anyone else was trying to do the same thing. (I know it isn't much code and i highly doubt anyone will want to add it to the source base but i figured some other poor schmuck will eventually end up doing this so i mine as well post it somewhere so they can easily find it =))
Any way here it is. Posted under the Public Domain (If i can? Not even sure considering that nhibernate is LGPL so ... essentially do whatever you'd like to with this without violating any of nhibernates license's.)
Code:
Imports NHibernate
Imports NHibernate.Cfg
Public Class myMySQL
Inherits NHibernate.Driver.ReflectionBasedDriver
Public Sub New()
MyBase.New("CoreLab.MySql", "CoreLab.MySql.MySqlConnection", "CoreLab.MySql.MySqlCommand")
End Sub
Public Overrides ReadOnly Property NamedPrefix() As String
Get
Return "?"
End Get
End Property
Public Overrides ReadOnly Property UseNamedPrefixInParameter() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property UseNamedPrefixInSql() As Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property SupportsMultipleOpenReaders() As Boolean
Get
Return False
End Get
End Property
Protected Overrides ReadOnly Property SupportsPreparingCommands() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property SupportsMultipleQueries() As Boolean
Get
Return True
End Get
End Property
End Class
The only thing I'd recommend is coming up with a more sane name for it. myMysql is a crappy name i used in my testing code to make sure it was okay. Anyway good luck and I'll answer any questions!