public async Task <ProductMuiltipleLanguage> GetByIdAsync(int id) { string cmd = $@"SELECT p.*, pl.* FROM aritrace.`product` p LEFT JOIN aritrace.`product_language` pl ON p.id = pl.product_id WHERE p.`id` = '{id}' and p.`is_deleted` = 0" ; var conn = DbConnection; if (conn == null) { conn = DALHelper.GetConnection(); } try { ProductMuiltipleLanguage product = null; using (var reader = await conn.QueryMultipleAsync(cmd, transaction: DbTransaction)) { return(reader.Read <Product, ProductLanguage, ProductMuiltipleLanguage>( (productRs, productLanguageRs) => { if (product == null) { var serializedParent = JsonConvert.SerializeObject(productRs); product = JsonConvert.DeserializeObject <ProductMuiltipleLanguage>(serializedParent); } if (productLanguageRs != null) { if (product.ProductLanguages == null) { product.ProductLanguages = new List <ProductLanguage>(); } product.ProductLanguages.Add(productLanguageRs); } return product; } ).FirstOrDefault()); } } catch (Exception) { throw; } finally { if (DbConnection == null) { conn.Dispose(); } } }
public UpdateProductCommand(ProductMuiltipleLanguage product) { Model = product; }
public InsertProductCommand(ProductMuiltipleLanguage product) { Model = product; }