コード例 #1
0
        public static void Insert(OrgChartConnection connection)
        {
            if (!UpdateDatabase)
            {
                var first = All().OrderByDescending(e => e.Id).FirstOrDefault();

                var id = 0;

                if (first != null)
                {
                    id = first.Id;
                }

                connection.Id = id + 1;

                All().Insert(0, connection);
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    db.OrgChartConnections.AddObject(connection);
                    db.SaveChanges();
                }
            }
        }
コード例 #2
0
        public static void Update(OrgChartConnection connection)
        {
            if (!UpdateDatabase)
            {
                var target = One(e => e.Id == connection.Id);

                if (target != null)
                {
                    target.FromShapeId = connection.FromShapeId;
                    target.ToShapeId = connection.ToShapeId;
                    target.Text = connection.Text;
                    target.FromPointX = connection.FromPointX;
                    target.FromPointY = connection.FromPointY;
                    target.ToPointX = connection.ToPointX;
                    target.ToPointY = connection.ToPointY;
                }
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    db.OrgChartConnections.Attach(connection);
                    db.ObjectStateManager.ChangeObjectState(connection, EntityState.Modified);
                    db.SaveChanges();
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the OrgChartConnections EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrgChartConnections(OrgChartConnection orgChartConnection)
 {
     base.AddObject("OrgChartConnections", orgChartConnection);
 }
コード例 #4
0
 /// <summary>
 /// Create a new OrgChartConnection object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static OrgChartConnection CreateOrgChartConnection(global::System.Int32 id)
 {
     OrgChartConnection orgChartConnection = new OrgChartConnection();
     orgChartConnection.Id = id;
     return orgChartConnection;
 }
コード例 #5
0
 public static void Delete(OrgChartConnection connection)
 {
     if (!UpdateDatabase)
     {
         var target = One(p => p.Id == connection.Id);
         if (target != null)
         {
             All().Remove(target);
         }
     }
     else
     {
         using (var db = new SampleEntities())
         {
             db.OrgChartConnections.Attach(connection);
             db.OrgChartConnections.DeleteObject(connection);
             db.SaveChanges();
         }
     }
 }