Question

I'm trying to connect to a Sybase IQ Database using Fluent NHibernate (or NHibernate directly if necessary) but I can't seem to find any examples or other input on what driver, dialect and connection string to use.

Any help would be appreciated.

Thanks

Was it helpful?

Solution

There is currently no NH driver or dialect for Sybase IQ, but it is pretty easy to write your own.

For the dialect you could try using the generic dialect, if this isn't a good fit then you will have to adapt one of the existing dialects. Please have a look at the below link for the source of current dialects:

https://github.com/nhibernate/nhibernate-core/tree/master/src/NHibernate/Dialect

For the driver the easiest option is to inherit from ReflectionBasedDriver. Please see below for an example class on how to do this:

public class IQClientDriver : NHibernate.Driver.ReflectionBasedDriver
{
    public IQClientDriver()
        : base("Full namespace + DB Provider name here", 
               "Full namespace + DB Connection class here", 
               "Full namespace + DB Command class here")
    { }

    public override bool UseNamedPrefixInSql
    { get { /* return true when the parameter names in SQL statements require a prefix */ } }

    public override bool UseNamedPrefixInParameter
    { get { /* return true when the parameters names require a prefix */ } }

    public override string NamedPrefix
    { get { /* return the parameters prefix string */  } }
}

To be able to configure Fluent Hibernate to use this new driver and dialect it will then be necessary to create a configuration class by inheriting from PersistenceConfiguration. Please see the following SO question for further details.

Is it possible to use (fluent)nhibernate with an odbc connection?

Alternatively to specify the driver and dialect in the NHibernate XML configuration file update the following entries to the new dialect and driver:

<property name="dialect">Your.NS.IQDialect, Your.DLL</property>
<property name="connection.driver_class">Your.NS.IQClientDriver, Your.DLL</property>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top