zoukankan      html  css  js  c++  java
  • castle ar 的update方法!!

    有这么一个领域类
     public class Task    {
            private Project project;
            /// <summary>
            /// 项目
            /// int
            /// </summary>
            [BelongsTo("Project")]
            public Project Project
            {
                get { return project; }
                set { project = value; }
            }
            private IList childrens;
            [HasMany(typeof(Task), Table = "Task", ColumnKey = "ParentTask")]
            public IList Childrens
            {
                get { return childrens; }
                set { childrens = value; }
            }
            private Task parentTask;
            /// <summary>
            /// 父任务
            /// </summary>
            [BelongsTo("ParentTask")]
            public Task ParentTask
            {
                get { return parentTask; }
                set { parentTask = value; }
            }
           private IList members;
            [HasMany(typeof(Member), Table = "Member", ColumnKey = "Task")]
            public IList Members
            {
                get { return members; }
                set { members= value; }
            }

    }
    这里我关注 private IList childrens;,,就是因为有这样一个关系存在,当Task在做更新(update)时候,除了发生本身的一个update外,,还会根据此关系发生'UPDATE Task SET ParentTask = null WHERE ParentTask = @p0', N'@p0 int', @p0 = 327681,,,这是因为task与自己的子task有一对多关系!!!

    以上是主外键在一个表时,,当主外在不同表中时,,比如上面的一个任务对应多个成员时,在更新任务后,也会紧紧跟一句生'UPDATE Member SET Task = null WHERE Task = @p0', N'@p0 int', @p0 = 327643,

    ==================
    注意:
    但是对于外键所在对象做更新时候,,,只更新自己,与其他对象不在发生任何联系

  • 相关阅读:
    86. Partition List
    328. Odd Even Linked List
    19. Remove Nth Node From End of List(移除倒数第N的结点, 快慢指针)
    24. Swap Nodes in Pairs
    2. Add Two Numbers(2个链表相加)
    92. Reverse Linked List II(链表部分反转)
    109. Convert Sorted List to Binary Search Tree
    138. Copy List with Random Pointer
    为Unity的新版ugui的Prefab生成预览图
    ArcEngine生成矩形缓冲区
  • 原文地址:https://www.cnblogs.com/pojia/p/851060.html
Copyright © 2011-2022 走看看