public async Task <CommonMessageClientType> QueryByID(Guid id)
        {
            CommonMessageClientType type = null;

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, _commonQueueConnectionFactory.CreateReadForCommonQueue(), 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 {0},{1} from [CommonMessageClientType] as t join [CommonQueueProductEndpoint] as e on t.endpointid=e.id where t.[id]=@id", StoreHelper.GetCommonQueueConsumeEndpointSelectFields("t"), StoreHelper.GetCommonQueueProductEndpointSelectFields("e"))
                })
                {
                    var parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                    {
                        Value = id
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();

                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            type = new CommonMessageClientType();
                            StoreHelper.SetCommonMessageClientTypeSelectFields(type, reader, "t");
                            type.Endpoint = new CommonQueueProductEndpoint();
                            StoreHelper.SetCommonQueueProductEndpointSelectFields(type.Endpoint, reader, "e");
                        }

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

            return(type);
        }
Exemple #2
0
        public async Task <CommonQueueProductEndpoint> QueryByID(Guid id)
        {
            CommonQueueProductEndpoint endpoint = null;

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, _commonQueueConnectionFactory.CreateReadForCommonQueue(), 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 {0} from [CommonQueueProductEndpoint] where [id]=@id", StoreHelper.GetCommonQueueProductEndpointSelectFields(string.Empty))
                })
                {
                    var parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                    {
                        Value = id
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();

                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            endpoint = new CommonQueueProductEndpoint();
                            StoreHelper.SetCommonQueueProductEndpointSelectFields(endpoint, reader, string.Empty);
                        }

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

            return(endpoint);
        }