Beispiel #1
0
        public static async Task <TQueryResult> PocoQuery <TQueryResult>(this IDbConnectionCreator connectionCreator, Func <Database, Task <TQueryResult> > executeFunc)
        {
            using (var connection = connectionCreator.CreateDbConnection())
            {
                if (connection.State != ConnectionState.Open)
                {
                    await connection.OpenAsync();
                }

                using (var db = CreateDatabase(connection))
                {
                    try
                    {
                        return(await executeFunc(db).ConfigureAwait(false));
                    }
                    catch (SqlException ex)
                    {
                        connectionCreator.RaiseExecuteErrorEvent(ex);
                        throw;
                    }
                    finally
                    {
                        connectionCreator.RaiseCommandsExecutedEvent();
                    }
                }
            }
        }
Beispiel #2
0
        public static TQueryResult PocoQuery <TQueryResult>(this IDbConnectionCreator connectionCreator, Func <Database, TQueryResult> executeFunc)
        {
            using (var connection = connectionCreator.CreateDbConnection())
            {
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }

                using (var db = CreateDatabase(connection))
                {
                    try
                    {
                        return(executeFunc(db));
                    }
                    catch (SqlException ex)
                    {
                        connectionCreator.RaiseExecuteErrorEvent(ex);
                        throw;
                    }
                    finally
                    {
                        connectionCreator.RaiseCommandsExecutedEvent();
                    }
                }
            }
        }
Beispiel #3
0
 private static IInternalSession GetSession(IDbConnectionCreator connectionCreator)
 {
     return new SessionV2(
         new VodbConnection(connectionCreator),
         new EntityTranslator(),
         new OrderedEntityMapper(),
         new ProxyCreator());
 }
Beispiel #4
0
 public SessionV1(IDbConnectionCreator connectionCreator)
     : base((IInternalSession)Engine.Get<ISession>("creator", connectionCreator))
 {
 }
Beispiel #5
0
 public Session(IDbConnectionCreator connectionCreator)
     : base(GetSession(connectionCreator))
 {
 }