public async Task <QueryResult <EnvironmentClaimGenerator> > QueryByPage(string name, int page, int pageSize)
        {
            QueryResult <EnvironmentClaimGenerator> result = new QueryResult <EnvironmentClaimGenerator>();

            //获取只读连接字符串
            var strConn = _contextConnectionFactory.CreateReadForContext();

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, strConn, async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"
		                           select @count= count(*) from EnvironmentClaimGenerator where [name] like @name

                                    select {0} from EnvironmentClaimGenerator where [name] like @name
                                    order by sequence
		                            offset (@pagesize * (@page - 1)) rows 
		                            fetch next @pagesize rows only;"        , StoreHelper.GetEnvironmentClaimGeneratorSelectFields(string.Empty))
                })
                {
                    var parameter = new SqlParameter("@name", SqlDbType.VarChar, 150)
                    {
                        Value = $"{name.ToSqlLike()}%"
                    };
                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@page", SqlDbType.Int)
                    {
                        Value = page
                    };
                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@pagesize", SqlDbType.Int)
                    {
                        Value = pageSize
                    };

                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@count", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.Output
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();

                    SqlDataReader reader = null;


                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            var generator = new EnvironmentClaimGenerator();
                            StoreHelper.SetEnvironmentClaimGeneratorSelectFields(generator, reader, string.Empty);
                            result.Results.Add(generator);
                        }

                        await reader.CloseAsync();

                        result.TotalCount  = (int)commond.Parameters["@count"].Value;
                        result.CurrentPage = page;
                    }
                }
            });

            return(result);
        }
        public async Task <EnvironmentClaimGenerator> QueryByName(string name)
        {
            EnvironmentClaimGenerator generator = null;

            DBTransactionHelper.SqlTransactionWork(DBTypes.SqlServer, true, false, _contextConnectionFactory.CreateReadForContext(), async(conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    CommandText = string.Format(@"select {0} from EnvironmentClaimGenerator where [name]=@name", StoreHelper.GetEnvironmentClaimGeneratorSelectFields(string.Empty)),
                    Transaction = sqlTran
                })
                {
                    var parameter = new SqlParameter("@name", SqlDbType.VarChar, 150)
                    {
                        Value = name
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();


                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            generator = new EnvironmentClaimGenerator();
                            StoreHelper.SetEnvironmentClaimGeneratorSelectFields(generator, reader, string.Empty);
                        }

                        await reader.CloseAsync();
                    }
                }
            });


            return(generator);
        }