Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
急!!!可以级联insert,不能级联update?
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
  8 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
 
try  
View profile  
 More options Dec 1 2006, 3:35 am
From: "try" <djsoft....@gmail.com>
Date: Fri, 01 Dec 2006 00:35:42 -0800
Local: Fri, Dec 1 2006 3:35 am
Subject: 急!!!可以级联insert,不能级联update?
 public interface Category : Entity
    {
        [PrimaryKey]
        int CategoryID { get; }
        string CategoryName { get; set; }
        [FkQuery("Category", Contained=true, LazyLoad=true)]
        Product[] Products
        {
            get;            set;
        }
    }
    public interface Product : Entity
    {
        [PrimaryKey]
        int ProductID { get; }
        string ProductName { get; set; }
        [FkReverseQuery(LazyLoad = true)]
        Category Category
        {
            get;       set;
        }
    }
=====insert===
Category category = new Category();
category.CategoryName = "11";
Product product = new Product();
product.ProductName = "1111";
ProductArrayList prarry = new ProductArrayList();
prarry.Add(product);
category.Products = prarry;
Gateway.Default.Save<Category>(category);
=====================执行结果正确,product表也被插入数据了

===update=======
Category category = new Category();
category.CategoryID=1;
category.Attach();  /////////////////////////////
(用find方法和手动效果一样)
category.CategoryName = "222222222";
Product product = new Product();
product.ProductName = "222222222222";
ProductArrayList prarry = new ProductArrayList();
prarry.Add(product);
category.Products = prarry;
Gateway.Default.Save<Category>(category);
=====================执行结果,只有category被更新
product表没有被更新

另:实际代码save使用
DbTransaction tran = Gateway.Default.BeginTransaction();
        int ret = 0;
        try
        {
            Gateway.Default.Save<Category>(category, tran);
            //Gateway.Default.Save<Product>(product, tran);
            tran.Commit();
        }
        catch
        {
            tran.Rollback();
        }
        finally
        {
            Gateway.Default.CloseTransaction(tran);
        }


    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  
 More options Dec 1 2006, 3:38 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 1 Dec 2006 16:38:18 +0800
Local: Fri, Dec 1 2006 3:38 am
Subject: Re: 急!!!可以级联insert,不能级联update?

update时,你的Category必须是find出来的,product才会被save。

On 12/1/06, try <djsoft....@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.
try  
View profile   Translate to Translated (View Original)
 More options Dec 1 2006, 3:58 am
From: "try" <djsoft....@gmail.com>
Date: Fri, 01 Dec 2006 00:58:25 -0800
Local: Fri, Dec 1 2006 3:58 am
Subject: Re: 急!!!可以级联insert,不能级联update?

我也试过用find方法,
不过输出的sql语句也只是 update category
这样对product赋值应该对否?
Product product = new Product();
product.ProductName = "222222222222";
ProductArrayList prarry = new ProductArrayList();
prarry.Add(product);


    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 Dec 1 2006, 4:22 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 1 Dec 2006 17:22:55 +0800
Local: Fri, Dec 1 2006 4:22 am
Subject: Re: 急!!!可以级联insert,不能级联update?

你可以试试
Product product = new Product();
product.ProductName = "222222222222";
//ProductArrayList prarry = new ProductArrayList();
cat.Products.Add(product);

On 12/1/06, try <djsoft....@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.
try  
View profile   Translate to Translated (View Original)
 More options Dec 1 2006, 4:33 am
From: "try" <djsoft....@gmail.com>
Date: Fri, 01 Dec 2006 01:33:44 -0800
Local: Fri, Dec 1 2006 4:33 am
Subject: Re: 急!!!可以级联insert,不能级联update?
不行

On 12月1日, 下午5时22分, Teddy <shijie...@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.
try  
View profile   Translate to Translated (View Original)
 More options Dec 1 2006, 4:55 am
From: "try" <djsoft....@gmail.com>
Date: Fri, 01 Dec 2006 01:55:43 -0800
Local: Fri, Dec 1 2006 4:55 am
Subject: Re: 急!!!可以级联insert,不能级联update?
基本能试的我都试了下。
此种类型也不行:
Product prdouct = category.prouct[0];
........

到底要咋样才能??

On 12月1日, 下午5时22分, Teddy <shijie...@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.
Teddy  
View profile   Translate to Translated (View Original)
 More options Dec 1 2006, 10:38 pm
From: Teddy <shijie...@gmail.com>
Date: Sat, 2 Dec 2006 11:38:17 +0800
Local: Fri, Dec 1 2006 10:38 pm
Subject: Re: 急!!!可以级联insert,不能级联update?

经检查测试,确认这是一个bug。非常抱歉给你造成不便,我会在下一版本中修覆改问题。

Teddy

On 12/1/06, try <djsoft....@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.
Teddy  
View profile   Translate to Translated (View Original)
 More options Dec 2 2006, 11:59 pm
From: Teddy <shijie...@gmail.com>
Date: Sun, 3 Dec 2006 12:59:42 +0800
Local: Sat, Dec 2 2006 11:59 pm
Subject: Re: 急!!!可以级联insert,不能级联update?

该问题已经在最新的v3.3.7版修复,请下载新版本。

On 12/2/06, Teddy <shijie...@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