Ejemplo n.º 1
0
        public async Task <KhoKiemKe> UpdatePartial(KhoKiemKe kiemke, params string[] field)
        {
            var a = await WithConnection(async c =>
            {
                KhoKiemKe obj = await c.GetAsync(kiemke);

                if (obj == null)
                {
                    throw new Exception(string.Format("Update id {0} not exist", kiemke.KiemKeId.ToString()));
                }
                var list = field.ToList();
                var partialUpdateMapping = OrmConfiguration
                                           .GetDefaultEntityMapping <KhoKiemKe>()
                                           .Clone()
                                           .UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true,
                                                                      list.ToArray());

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

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

                return(kiemke);
            });

            return(a);
        }
Ejemplo n.º 2
0
        public async Task <KhoKiemKe> Insert(KhoKiemKe kiemke)
        {
            return(await WithConnection(async c =>
            {
                await c.InsertAsync(kiemke);

                if (kiemke.KiemKeId == 0)
                {
                    throw new Exception("Insert Fail");
                }

                return kiemke;
            }));
        }
Ejemplo n.º 3
0
        public async Task <KhoKiemKe> Update(KhoKiemKe kiemke)
        {
            return(await WithConnection(async c =>
            {
                KhoKiemKe obj = await c.GetAsync(kiemke);

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

                var result = await c.UpdateAsync(kiemke);

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

                return kiemke;
            }));
        }