public static object SelectScalar(string sqlString, DataAccessParameterCollection paraCollection) { using (DataAccessBroker broker = DataAccessFactory.Instance()) { return(broker.ExecuteScalar(sqlString, paraCollection, CommandType.Text)); } }
/// <summary> /// ExecuteScalar 并返还回唯一值 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="wb"></param> /// <param name="defaultValue"></param> /// <returns></returns> public static T ExecuteScalar <T>(WhereBuilder wb, T defaultValue) { using (DataAccessBroker broker = DataAccessFactory.Instance()) { object result = broker.ExecuteScalar(wb); if (result != null && result != DBNull.Value) { defaultValue = (T)result; } } return(defaultValue); }