System.Data.Common.DbConnection.Close C# (CSharp) Method

Close() public abstract method

public abstract Close ( ) : void
return void
        public abstract void Close();

Usage Example

Exemplo n.º 1
0
        private static async Task <IEnumerable <TReturn> > MultiMapAsync <TReturn>(this IDbConnection cnn, CommandDefinition command, Type[] types, Func <object[], TReturn> map, string splitOn)
        {
            if (types.Length < 1)
            {
                throw new ArgumentException("you must provide at least one type to deserialize");
            }

            object param     = command.Parameters;
            var    identity  = new Identity(command.CommandText, command.CommandType, cnn, types[0], param?.GetType(), types);
            var    info      = GetCacheInfo(identity, param, command.AddToCache);
            bool   wasClosed = cnn.State == ConnectionState.Closed;

            try {
                if (wasClosed)
                {
                    await((DbConnection)cnn).OpenAsync().ConfigureAwait(false);
                }
                using (var cmd = (DbCommand)command.SetupCommand(cnn, info.ParamReader))
                    using (var reader = await cmd.ExecuteReaderAsync(command.CancellationToken).ConfigureAwait(false)) {
                        var results = MultiMapImpl <TReturn>(null, default(CommandDefinition), types, map, splitOn, reader, identity, true);
                        return(command.Buffered ? results.ToList() : results);
                    }
            }
            finally {
                if (wasClosed)
                {
                    cnn.Close();
                }
            }
        }
All Usage Examples Of System.Data.Common.DbConnection::Close