当前位置: 首页>>代码示例>>C#>>正文


C# DB.DeleteObject方法代码示例

本文整理汇总了C#中DowntimeCollection_Demo.DB.DeleteObject方法的典型用法代码示例。如果您正苦于以下问题:C# DB.DeleteObject方法的具体用法?C# DB.DeleteObject怎么用?C# DB.DeleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DowntimeCollection_Demo.DB的用法示例。


在下文中一共展示了DB.DeleteObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: saveAllPostRows

        private string saveAllPostRows()
        {
            List<PostRowData> dd = getPostRowDatas();
            if (dd == null) return "no data";

            using (DB db = new DB(DBHelper.GetConnectionString(_currentClient)))
            {
                DowntimeReason dr;
                foreach (var item in dd)
                {

                    var levels = item.Path.Split('>');
                    if (levels.Length < 3) Array.Resize(ref levels, 3);
                    if (string.IsNullOrEmpty(levels[0]) && string.IsNullOrEmpty(levels[1]) && string.IsNullOrEmpty(levels[2])) continue;

                    if (item.Id <= 0)
                    {
                        dr = new DowntimeReason
                        {
                            Level1 = levels[0],
                            Level2 = levels[1],
                            Level3 = levels[2],
                            Duration = item.Duration,
                            Client = _currentClient,
                            HideReasonInReports = item.HideReasonInReports,
                            Line = (!string.IsNullOrEmpty(Line) ? Line : "company-demo"),
                            IsChangeOver = item.IsChangeOver
                        };
                        db.AddToDowntimeReasonSet(dr);
                    }
                    else
                    {
                        var q = from o in db.DowntimeReasonSet
                                where o.ID == item.Id
                                && o.Client == _currentClient
                                select o;
                        dr = q.FirstOrDefault();

                        if (dr == null) continue;

                        if ((string.IsNullOrEmpty(dr.Line) || dr.Line == "company-demo") && (!string.IsNullOrEmpty(Line) && Line != "company-demo"))//assumes it is a global reason code and they're adding a Line specific
                        {
                            DowntimeReason reason = new DowntimeReason
                            {
                                Level1 = levels[0],
                                Level2 = levels[1],
                                Level3 = levels[2],
                                Duration = item.Duration,
                                HideReasonInReports = item.HideReasonInReports,
                                Line = (!string.IsNullOrEmpty(Line) ? Line : "company-demo"),
                                IsChangeOver = item.IsChangeOver,
                                Client = _currentClient
                            };

                            db.AddToDowntimeReasonSet(reason);
                        }
                        else
                        {
                            dr.Level1 = levels[0];
                            dr.Level2 = levels[1];
                            dr.Level3 = levels[2];
                            dr.Duration = item.Duration;
                            dr.HideReasonInReports = item.HideReasonInReports;
                            dr.Line = (!string.IsNullOrEmpty(Line) ? Line : "company-demo");
                            dr.IsChangeOver = item.IsChangeOver;
                        }
                    }
                }

                //delete rows
                foreach (var item in getPostRowDatasDeleteRows())
                {
                     var q = from o in db.DowntimeReasonSet
                                where o.ID == item
                                && o.Client == _currentClient
                                select o;
                        dr = q.FirstOrDefault();
                    if (dr == null) continue;
                    if(dr.Line == Line)//Don't want to accidently delete another Line's reason code
                        db.DeleteObject(dr);
                }

                db.SaveChanges();
                return "true";
            }
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:86,代码来源:Service.ashx.cs

示例2: DeleteOption

        public string DeleteOption()
        {
            int id;

            int.TryParse(request.Form["id"], out id);

            if (id <= -1) return "FAILED";
            using (DB db = new DB(DBHelper.GetConnectionString(_currentClient)))
            {
                Options tp = (from o in db.Options
                    where o.Id == id
                    select o).FirstOrDefault();

                if (tp == null) return "FAILED";
                db.DeleteObject(tp);
                int results = db.SaveChanges();

                if (results >= 0)
                    return "SUCCESS";
            }

            return "FAILED";
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:23,代码来源:Service.ashx.cs

示例3: delRecords

        private string delRecords()
        {
            string ids = request["ids"];
            if (string.IsNullOrEmpty(ids)) return "Invald args.";

            using (DB db = new DB(DBHelper.GetConnectionString(_currentClient)))
            {
                foreach (var item in ids.Split(','))
                {
                    int id;
                    if (!int.TryParse(item, out id)) continue;

                    var q = from o in db.DowntimeDataSet
                        where o.ID == id
                        select o;
                    var row = q.FirstOrDefault();
                    if (row != null)
                    {
                        db.DeleteObject(row);
                    }
                }
                db.SaveChanges();
            }
            return "true";
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:25,代码来源:Service.ashx.cs

示例4: DeleteGoal

        public static bool DeleteGoal(int id)
        {
            using (DB db = new DB())
            {
                var q = from o in db.GoalSet
                        where o.Id == id
                        select o;

                Goal goal = q.FirstOrDefault();
                if (goal == null) return false;
                db.DeleteObject(goal);
                return db.SaveChanges() > 0;
            }
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:14,代码来源:MillardDashboardHelper.cs

示例5: Delete

        public static bool Delete(int id)
        {
            using (DB db = new DB(DBHelper.GetConnectionString()))
            {
                DigestEmail email = (from o in db.DigestEmails
                                     where o.Id == id
                                     select o).FirstOrDefault();

                if (email != null)
                {
                    db.DeleteObject(email);

                    return db.SaveChanges() > 0;
                }

            }

            return false;
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:19,代码来源:DigestEmailView.cs

示例6: DeleteLine

        public static void DeleteLine(int emailId, string line)
        {
            using (DB db = new DB(DBHelper.GetConnectionString()))
            {
                DigestEmail email = (from o in db.DigestEmails
                                     where o.Id == emailId
                                     select o).FirstOrDefault();

                if (email != null)
                {
                    email.DigestEmailLines.Load();

                    DigestEmailLine emailLine = (from o in email.DigestEmailLines
                                                 where o.Line == line
                                                 select o).FirstOrDefault();

                    if (emailLine != null)
                    {
                        db.DeleteObject(emailLine);

                        db.SaveChanges();
                    }
                }
            }
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:25,代码来源:DigestEmailView.cs

示例7: DeleteFromClient

        public static bool DeleteFromClient(int id, string client)
        {
            using (DB db = new DB(DBHelper.GetConnectionString()))
            {
                DigestEmail email = (from o in db.DigestEmails
                                     where o.Id == id
                                     && o.Client == client
                                     select o).FirstOrDefault();

                if (email != null)
                {
                    email.DigestEmailLines.Load();

                    foreach (DigestEmailLine line in email.DigestEmailLines.ToList())
                        db.DeleteObject(line);

                    db.DeleteObject(email);

                    return db.SaveChanges() > 0;
                }

            }

            return false;
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:25,代码来源:DigestEmailView.cs


注:本文中的DowntimeCollection_Demo.DB.DeleteObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。