コード例 #1
0
        /// <summary>
        /// 异步获取传输对象
        /// </summary>
        /// <typeparam name="TDto">传输对象类型</typeparam>
        /// <param name="condition">查询条件</param>
        /// <param name="ignoreFields">忽略的字段</param>
        /// <param name="isWrite">是否为写连接(事务中使用)</param>
        /// <returns>传输对象</returns>
        public Task <TDto> GetDtoAsync <TDto>(Expression <Func <T, bool> > condition, string[] ignoreFields = null, bool isWrite = false)
        {
            SqlQuery query = SqlQueryUtil.BuilderQueryTopSqlQuery <TDto, T>(condition, TableName, topCount: 1, ignoreFields: ignoreFields, dbType: isWrite ? WriterDataType : ReaderDataType);

            return(GetDataAccess(isWrite: isWrite).QuerySingleOrDefaultAsync <TDto>(query));
        }
コード例 #2
0
        /// <summary>
        /// 获取传输对象
        /// </summary>
        /// <typeparam name="TDto">传输对象类型</typeparam>
        /// <param name="condition">查询条件</param>
        /// <param name="ignoreFields">忽略的字段</param>
        /// <param name="isWrite">是否为写连接(事务中使用)</param>
        /// <returns>传输对象</returns>
        public TDto GetDto <TDto>(object condition, string[] ignoreFields = null, bool isWrite = false)
        {
            SqlQuery query = SqlQueryUtil.BuilderQueryTopSqlQuery <TDto>(condition, TableName, topCount: 1, ignoreFields: ignoreFields, dbType: isWrite ? WriterDataType : ReaderDataType);

            return(GetDataAccess(isWrite: isWrite).QuerySingleOrDefault <TDto>(query));
        }
コード例 #3
0
        /// <summary>
        /// 获取模型
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="ignoreFields"></param>
        /// <param name="isWrite"></param>
        /// <returns></returns>
        public T GetInfo(Expression <Func <T, bool> > condition, string[] ignoreFields = null, bool isWrite = false)
        {
            SqlQuery query = SqlQueryUtil.BuilderQueryTopSqlQuery <T>(condition, TableName, topCount: 1, dbType: ReaderDataType);

            return(GetDataAccess().QuerySingleOrDefault <T>(query));
        }
コード例 #4
0
        /// <summary>
        /// 异步获取单个对象
        /// </summary>
        /// <param name="condition">获取条件</param>
        /// <param name="ignoreFields">忽略的字段</param>
        /// <param name="isWrite">是否为写连接(事务中使用)</param>
        /// <returns>传输对象</returns>
        public Task <T> GetInfoAsync(object condition, string[] ignoreFields = null, bool isWrite = false)
        {
            SqlQuery query = SqlQueryUtil.BuilderQueryTopSqlQuery(condition, TableName, topCount: 1, dbType: isWrite ? WriterDataType : ReaderDataType);

            return(GetDataAccess(isWrite: isWrite).QuerySingleOrDefaultAsync <T>(query));
        }
コード例 #5
0
        /// <summary>
        /// 获取DTO
        /// </summary>
        /// <typeparam name="TDto"></typeparam>
        /// <param name="condition"></param>
        /// <param name="ignoreFields"></param>
        /// <param name="isWrite"></param>
        /// <returns></returns>
        public Task <TDto> GetDtoAsync <TDto>(Expression <Func <T, bool> > condition, string[] ignoreFields = null, bool isWrite = false)
        {
            SqlQuery query = SqlQueryUtil.BuilderQueryTopSqlQuery <T>(condition, TableName, topCount: 1, dbType: ReaderDataType);

            return(GetDataAccess().ExecuteScalarAsync <TDto>(query));
        }