예제 #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();
                    }
                }
            }
        }
예제 #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();
                    }
                }
            }
        }
예제 #3
0
파일: Session.cs 프로젝트: stalinvr007/VoDB
 private static IInternalSession GetSession(IDbConnectionCreator connectionCreator)
 {
     return new SessionV2(
         new VodbConnection(connectionCreator),
         new EntityTranslator(),
         new OrderedEntityMapper(),
         new ProxyCreator());
 }
예제 #4
0
 public SessionV1(IDbConnectionCreator connectionCreator)
     : base((IInternalSession)Engine.Get<ISession>("creator", connectionCreator))
 {
 }
예제 #5
0
파일: Session.cs 프로젝트: stalinvr007/VoDB
 public Session(IDbConnectionCreator connectionCreator)
     : base(GetSession(connectionCreator))
 {
 }