Exemple #1
0
        public void Save()
        {
            var dc = new RobotBehaviorsDataContext(SqlConnectionString);

            if (this.Id == 0)
            {
                var robotBehaviorToPerson = new RobotBehaviorToPerson();
                robotBehaviorToPerson.DeviceId        = this.DeviceId;
                robotBehaviorToPerson.PersonId        = this.PersonId;
                robotBehaviorToPerson.RobotBehaviorId = this.RobotBehaviorId;
                robotBehaviorToPerson.Status          = this.Status;
                robotBehaviorToPerson.Weather         = this.Weather;
                robotBehaviorToPerson.IsDeleted       = this.IsDeleted;
                robotBehaviorToPerson.CreatedAt       = DateTime.Now;

                dc.RobotBehaviorToPersons.InsertOnSubmit(robotBehaviorToPerson);
                dc.SubmitChanges();

                this.Id        = robotBehaviorToPerson.Id;
                this.CreatedAt = robotBehaviorToPerson.CreatedAt;
            }
            else
            {
                var records =
                    from n in dc.RobotBehaviorToPersons
                    where n.Id == this.Id
                    select n;

                foreach (var r in records)
                {
                    r.PersonId        = this.PersonId;
                    r.RobotBehaviorId = this.RobotBehaviorId;
                    r.Status          = this.Status;
                    r.Weather         = this.Weather;
                    r.IsDeleted       = this.IsDeleted;
                    r.UpdatedAt       = DateTime.Now;
                }
                dc.SubmitChanges();
            }
        }
 partial void DeleteRobotBehaviorToPerson(RobotBehaviorToPerson instance);
 partial void UpdateRobotBehaviorToPerson(RobotBehaviorToPerson instance);
 partial void InsertRobotBehaviorToPerson(RobotBehaviorToPerson instance);