-2

My last question was closed because it was interpreted as "broad and vague" so I will try to clear things up.

I need to create a custom Driver to NHibernate to do some stuff(not important to the post) but I don't know where to start. I have a code that I saw on the internet but I don't know how to complete it:

public class teste : NHibernate.Driver.ReflectionBasedDriver
{
    public teste()
        :base()
    {

    }

My problem is in the :base() part, I don't know what I need to put there !

Thanks

P.S-> For god's sake, that's not a duplicate post since the last one was closed !

Leonardo
  • 3,141
  • 3
  • 31
  • 60

1 Answers1

1

This question is doomed as "I want to do stuff" doesn't really help us. You would use ReflectionBasedDriver if NHibernate expects one assembly but you need to use another.

For example if I wanted to use mono sqlite (as NHibernate expects SQLite.NET) then I would use:-

    public MyClass() : base("Mono.Data.Sqlite", 
        "Mono.Data.Sqlite.SqliteConnection", "Mono.Data.Sqlite.SqliteCommand")
    {

    public override bool UseNamedPrefixInSql
    {
        get { return true; }
    }

    public override bool UseNamedPrefixInParameter
    {
        get { return true; }
    }

    public override string NamedPrefix
    {
        get { return "@"; }
    }
}

I highly suspect you are in actual fact after this:

public class MyDialect : NHibernate.Dialect.MsSql2008Dialect
{
}

As a custom dialect allows you to specify your own configuration.

Rippo
  • 22,117
  • 14
  • 78
  • 117
  • Thanks Rippo. No, I can't use Dialect, 'cause what I want to do can't be done via Dialect (intercept a LINQ call, to change the sql code). Do you think it will work with linq ? Thanks ! – Leonardo Apr 17 '12 at 17:52
  • Intercepting should be done via interceptors NOT ReflectionBasedDriver – Rippo Apr 18 '12 at 07:42
  • 1
    BTW You already have an answer for this. http://stackoverflow.com/questions/9933002/dialect-driver-every-select-i-perform-add-withnolock – Rippo Apr 18 '12 at 07:45
  • No, its not answered. What I need is, when the sql query is performed, the "with(nolock)" must be in the query (I mean, you must see it after the "from table_x with(nolock)". Using LINQ, it just doesn't stop at the onPrepare, so I assume that customizing a driver would do the job. Got it ? Thanks ! – Leonardo Apr 18 '12 at 13:31
  • It is: `session.BeginTransaction(IsolationLevel.ReadUncommitted);` DOES exactly the same thing. Your only hope is to use this or fall back to – Rippo Apr 18 '12 at 15:26
  • So, with LINQ no chance to see add with(nolock) directly to the sql code ? Thanks – Leonardo Apr 18 '12 at 16:13