Subsonic 3 Simple Repository And Transactions

Posted by ChrisKolenko on Stack Overflow See other posts from Stack Overflow or by ChrisKolenko
Published on 2009-07-16T05:16:55Z Indexed on 2010/05/12 19:04 UTC
Read the original article Hit count: 474

Filed under:

Hey everyone,

So this is what I have so far. Am I doing something wrong or is there a bug in 3.0.0.3?

    var Repository = new SimpleRepository("DBConnectionName");

    using (TransactionScope ts = new TransactionScope())
    {
        using (SharedDbConnectionScope scs = new SharedDbConnectionScope("connstring", "providerName"))
        {
            try
            {
                for (int i = 0; i < 5; i++)
                {
                    Supplier s = new Supplier();
                    s.SupplierCode = i.ToString();
                    s.SupplierName = i.ToString();

                    Repository.Add<Supplier>(s);
                }

                ts.Complete();
            }
            catch
            {
            }
        }
    }

I'm getting an error in SubSonic DbDataProvider public DbConnection CurrentSharedConnection { get { return __sharedConnection; }

        protected set
        {
            if(value == null)
            {
                __sharedConnection.Dispose();

etc.. __sharedConnection == null :( Object Null Reference Exception :(

© Stack Overflow or respective owner

Related posts about subsonic3