public SqlDataReader ExecuteReader() { using (QueryTime.Measure(this)) { return(this.sqlCommand.ExecuteReader()); } }
public int ExecuteNonQuery() { using (QueryTime.Measure(this)) { return(this.sqlCommand.ExecuteNonQuery()); } }
public SqlDataReader ExecuteReader(CommandBehavior behavior) { using (QueryTime.Measure(this)) { return(this.sqlCommand.ExecuteReader(behavior)); } }
public T SelectSingleValue <T>() { if (SqlCommand.Connection == null) { throw new InvalidOperationException("SqlCommand.Connection is not set."); } using (QueryTime.Measure(this)) { var value = sqlCommand.ExecuteScalar(); if (value == null) { return(default(T)); } // Special case for Id<> and LongId<> var targetConvertType = typeof(T); if (IdTypeExtension.IsIdType(targetConvertType)) { var constructor = targetConvertType.GetConstructor(new[] { typeof(int) }); if (constructor == null) { throw new InvalidCastException("The Id<> type has no constructor taking int as a parameter."); } return((T)constructor.Invoke(new object[] { Convert.ToInt32(value) })); } else if (LongIdTypeExtension.IsLongIdType(targetConvertType)) { var constructor = targetConvertType.GetConstructor(new[] { typeof(long) }); if (constructor == null) { throw new InvalidCastException("The LongId<> type has no constructor taking long as a parameter."); } return((T)constructor.Invoke(new object[] { Convert.ToInt64(value) })); } // Just execute the query, don't close the connection return(DataRowExtensionsCustom.Get <T>(value)); } }