コード例 #1
0
        public async Task <KhoHangSanXuat> UpdatePartial(KhoHangSanXuat nuocsx, params string[] field)
        {
            var a = await WithConnection(async c =>
            {
                KhoHangSanXuat obj = await c.GetAsync(nuocsx);

                if (obj == null)
                {
                    throw new Exception(string.Format("Update id {0} not exist", nuocsx.HangSanXuatId.ToString()));
                }

                var list = field.ToList();
                var partialUpdateMapping = OrmConfiguration
                                           .GetDefaultEntityMapping <KhoHangSanXuat>()
                                           .Clone()
                                           .UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true,
                                                                      list.ToArray());

                var result = await c.UpdateAsync(nuocsx, statement => statement.WithEntityMappingOverride(partialUpdateMapping));

                if (result != true)
                {
                    throw new Exception("Update Fail");
                }

                return(nuocsx);
            });

            return(a);
        }
コード例 #2
0
        public async Task <KhoHangSanXuat> Insert(KhoHangSanXuat nuocsx)
        {
            return(await WithConnection(async c =>
            {
                await c.InsertAsync(nuocsx);

                if (nuocsx.HangSanXuatId == 0)
                {
                    throw new Exception("Insert Fail");
                }

                return nuocsx;
            }));
        }
コード例 #3
0
        public async Task <KhoHangSanXuat> Update(KhoHangSanXuat nuocsx)
        {
            return(await WithConnection(async c =>
            {
                KhoHangSanXuat obj = await c.GetAsync(nuocsx);

                if (obj == null)
                {
                    throw new Exception(string.Format("Update id {0} not exist", nuocsx.HangSanXuatId.ToString()));
                }

                var result = await c.UpdateAsync(nuocsx);

                if (result != true)
                {
                    throw new Exception("Update Fail");
                }

                return nuocsx;
            }));
        }