Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
能否对ORM_Tutorial示例中的User和Group的 多对多关系做一个Save的演示
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
fengmk2@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 8:58 am
From: "feng...@gmail.com" <feng...@gmail.com>
Date: Thu, 16 Nov 2006 13:58:01 -0000
Local: Thurs, Nov 16 2006 8:58 am
Subject: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示
即如何将一个User和一个Group关联?保存顺序是否有要求?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 9:22 am
From: Teddy <shijie...@gmail.com>
Date: Thu, 16 Nov 2006 22:22:51 +0800
Local: Thurs, Nov 16 2006 9:22 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

ORM_Tutorial教程中有非级联更新的User Group关联保存演示。

当Groups属性包含Contained=true修饰时,则,save user时,Groups能自动级联保存。

Teddy

On 11/16/06, feng...@gmail.com <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 9:23 am
From: MK2 <feng...@gmail.com>
Date: Thu, 16 Nov 2006 22:23:26 +0800
Local: Thurs, Nov 16 2006 9:23 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

我尝试了这种方法:
UserRole ur = new UserRole();
        ur.UserID = user.ID;
        ur.RoleID = role.ID;
        gateway.Save<UserRole>(ur);

On 11/16/06, feng...@gmail.com <feng...@gmail.com> wrote:

> 即如何将一个User和一个Group关联?保存顺序是否有要求?

--
能Web就Web.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 9:33 am
From: Teddy <shijie...@gmail.com>
Date: Thu, 16 Nov 2006 22:33:54 +0800
Local: Thurs, Nov 16 2006 9:33 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

如果用这种方法的话,需要保证user和role在userrole保存之前先保存。

On 11/16/06, MK2 <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 9:41 am
From: MK2 <feng...@gmail.com>
Date: Thu, 16 Nov 2006 22:41:18 +0800
Local: Thurs, Nov 16 2006 9:41 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

原来早就有例子了,呵呵,我一开始只看Adv的示例,呵呵,打搅了。
我觉得还是用这种不关联的方式比较好,如果关联了,删除了其中一个,那么它关联的也会被删除吧?

On 11/16/06, Teddy <shijie...@gmail.com> wrote:

--
能Web就Web.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 9:44 am
From: Teddy <shijie...@gmail.com>
Date: Thu, 16 Nov 2006 22:44:31 +0800
Local: Thurs, Nov 16 2006 9:44 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

是的。可以根据需要来,有时级联更新也需要,但大多数时候,多对多关联不需要这样的级联更新/删除。

On 11/16/06, MK2 <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 10:23 am
From: MK2 <feng...@gmail.com>
Date: Thu, 16 Nov 2006 23:23:20 +0800
Local: Thurs, Nov 16 2006 10:23 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

在ORM_Adv中,若直接使用User,而不用LocalUser,执行下面这段代码,会出错。
Entities.User oUser = new User();
        oUser.Birthday = DateTime.Now;
        gateway.Save<Entities.User>(oUser);
        oUser.Birthday = DateTime.Now;
        gateway.Save<Entities.User>(oUser);

错误代码如下:集合已修改;可能无法执行枚举操作。
换成LocalUser,则不会出错。


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 11:13 am
From: MK2 <feng...@gmail.com>
Date: Fri, 17 Nov 2006 00:13:15 +0800
Local: Thurs, Nov 16 2006 11:13 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

对于这种一对多自关联,Save的顺序又是怎样的?在ORM_Adv示例中只是使用了PerantID外键。。。。

public interface Group : Entity

    {

        [PrimaryKey]

        Guid ID { get; set; }

        string Name { get; set; }

        [FkReverseQuery(LazyLoad=true)]

        [MappingName("ParentID")]

        Group ParentGroup { get; set; }

        [FkQuery("ParentGroup", LazyLoad=true)]

        [SerializationIgnore]

        Group[] ChildGroups { get; set; }
    }

每次创建一个Group,PatentID该如何付值呢?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 6:49 pm
From: Teddy <shijie...@gmail.com>
Date: Fri, 17 Nov 2006 07:49:17 +0800
Local: Thurs, Nov 16 2006 6:49 pm
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

前一个问题已经确认是bug,我会修复。第二个问题,其实也算v3.2.5的一个bug,
原来,我会为标注FkReverseQuery的属性自动生成外键约束,但事实证明是不行的,像这种情况就不能设置外键约束,否则,root元素的Parent ID就不知放什么值了。所以我已经改成,不自动对FkReverseQuery属性生成外键约束了,如果需要外键约束的,需要同时标注FriendKeyAtt ribute。

谢谢你的测试,你真的很细心,绝对有测试的天赋~~

Teddy

On 11/17/06, MK2 <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 16 2006, 9:47 pm
From: MK2 <feng...@gmail.com>
Date: Fri, 17 Nov 2006 10:47:04 +0800
Local: Thurs, Nov 16 2006 9:47 pm
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

):
要不是有NBear,可能已经对底层数据库彻底地放弃了`````呵呵,为了尽快地熟悉NBear,还看了许多之前不想看的SQL语法,再看回NBear生成的 SQL脚本,领会了许多表与表的关联方式。因为自己之前做的开发,一点表与表的关联都没有,甚至连视图都少用,呵呵,所以真的是感谢NBear,不仅让ORM的 实现如此简单,还使我上了一堂宝贵的课。

On 11/17/06, Teddy <shijie...@gmail.com> wrote:

--
能Web就Web.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 18 2006, 4:36 am
From: MK2 <feng...@gmail.com>
Date: Sat, 18 Nov 2006 17:36:56 +0800
Local: Sat, Nov 18 2006 4:36 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

一对多自关联中的问题:
Category的Parent设置了FkReverseQuery ,生存的SQL脚本 "[ParentID] int NULL"
是Int型,但是如果不对Parent赋值,运行时逻辑如下:

Text INSERT INTO [Category] ( [Name], [Description], [ParentID], [Sort],
[User_ID], [Group_ID], [Visible] ) VALUES ( @Name, @Description, @ParentID,
@Sort, @User_ID, @Group_ID, @Visible ); SELECT SCOPE_IDENTITY()
Parameters:
@Name[String] = CategoryName
@Description[String] = Category
@ParentID[String] =
@Sort[Int32] = 0
@User_ID[Int32] = 2
@Group_ID[Int32] = 2
@Visible[Boolean] = True
这显示是错误了,但是如果对Parent赋值了,则正常,如:@ParentID[int32] = 1。

呵呵,测试来晚``````


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 18 2006, 4:42 am
From: Teddy <shijie...@gmail.com>
Date: Sat, 18 Nov 2006 17:42:48 +0800
Local: Sat, Nov 18 2006 4:42 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

恩,确实是个问题,我会修正它~~

On 11/18/06, MK2 <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 18 2006, 9:11 am
From: MK2 <feng...@gmail.com>
Date: Sat, 18 Nov 2006 22:11:05 +0800
Local: Sat, Nov 18 2006 9:11 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

是否问题还存在````始终还是@ParentID[String] =
正确应该是@ParentID[int] = 0

我已经更新到3.3.3了。


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 18 2006, 9:38 am
From: Teddy <shijie...@gmail.com>
Date: Sat, 18 Nov 2006 22:38:19 +0800
Local: Sat, Nov 18 2006 9:38 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

保存有没有出错呢?正确的应该@ParentID[int]=
等于后面没东西,因为ParentID默认是int?类型的。

你能把实体设计的代码发出来吗?

我会再测试一下。

On 11/18/06, MK2 <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile  
 More options Nov 18 2006, 9:48 am
From: MK2 <feng...@gmail.com>
Date: Sat, 18 Nov 2006 22:48:44 +0800
Local: Sat, Nov 18 2006 9:48 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

1对多的自关联:

        [FkReverseQuery(LazyLoad = true)]
        [MappingName("ParentID")]
        [SerializationIgnore]
        Category Parent
        {
            get;
            set;
        }

        [FkQuery("Parent", OrderBy = "{Name} DESC", LazyLoad = true)]
        Category[] Childs
        {
            get;
            set;
        }

Category cat = new Category();

        WriteLine("Save ParentCategory:");
        gateway.Save<Category>(cat);

        Category childCat = new Category();
        childCat.Parent = cat;
        gateway.Save<Category>(childCat);

gateway.Save<Category>(cat)的运行时中就出现了我之前所说的情况,而gateway.Save<Category>(childC at)则正常。也就是说,没有指定Parent时,默认会被设置成@ParentID[String]=
,而不是@Parent[int]=0


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MK2  
View profile   Translate to Translated (View Original)
 More options Nov 18 2006, 9:49 am
From: MK2 <feng...@gmail.com>
Date: Sat, 18 Nov 2006 22:49:56 +0800
Local: Sat, Nov 18 2006 9:49 am
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

生成的数据库中,ParengID列是整型的,保存空字符到该列,没有出现错误。

On 11/18/06, Teddy <shijie...@gmail.com> wrote:

--
能Web就Web.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 18 2006, 8:23 pm
From: Teddy <shijie...@gmail.com>
Date: Sun, 19 Nov 2006 09:23:05 +0800
Local: Sat, Nov 18 2006 8:23 pm
Subject: Re: 能否对ORM_Tutorial示例中的User和Group的多对多关系做一个Sa ve的演示

已经再次修正,你下载v3.3.4再测一下。

On 11/18/06, MK2 <feng...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google