Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
使用GridView时的问题
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
  15 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
 
寻路者  
View profile  
 More options Dec 14 2006, 10:45 pm
From: "寻路者" <181443...@qq.com>
Date: Thu, 14 Dec 2006 19:45:55 -0800
Local: Thurs, Dec 14 2006 10:45 pm
Subject: 使用GridView时的问题
例如我有2个实体
public interface T_City:Entity
    {

        [PrimaryKey]
        string City_ID
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        [NotNull]
        string City_Name
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        [NotNull]
        string Province_Name
        {
            get;
            set;
        }

        [SqlType("nvarchar(256)")]
        string Explain
        {
            get;
            set;
        }
[FkQuery("City_ID", Contained = true, LazyLoad = true)]
        [SerializationIgnore]
        T_Consumer[] Consumers
        {
            get;
            set;
        }

}

public interface T_Consumer:Entity
    {

        [PrimaryKey]
        string Consumer_ID
        {
            get;
            set;
        }

        [NotNull]
        string PWD
        {
            get;
            set;
        }

        [SqlType("nvarchar(2)")]
        string Sex
        {
            get;
            set;
        }

        DateTime Birthday
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        string Education
        {
            get;
            set;
        }

        string City_ID
        {
            get;
            set;
        }
    }
想用GridView显示Consumer的内容,但是我想显示的是City_Name,而City_ID是个无意义的主键值,是不是必须要建个视图实体才行? 有没有好的方法,因为如果建视图的话,在表多的话会很多.


    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.
寻路者  
View profile  
 More options Dec 14 2006, 10:55 pm
From: "寻路者" <181443...@qq.com>
Date: Thu, 14 Dec 2006 19:55:20 -0800
Local: Thurs, Dec 14 2006 10:55 pm
Subject: 使用GridView时的问题
例如我现在2个实体
public interface T_Consumer:Entity
    {

        [PrimaryKey]
        string Consumer_ID
        {
            get;
            set;
        }

        [NotNull]
        string PWD
        {
            get;
            set;
        }

        [SqlType("nvarchar(2)")]
        string Sex
        {
            get;
            set;
        }

        DateTime Birthday
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        string Education
        {
            get;
            set;
        }

        string City_ID
        {
            get;
            set;
        }

    }

public interface T_City:Entity
    {

        [PrimaryKey]
        string City_ID
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        [NotNull]
        string City_Name
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        [NotNull]
        string Province_Name
        {
            get;
            set;
        }

        [SqlType("nvarchar(256)")]
        string Explain
        {
            get;
            set;
        }

        [FkQuery("City_ID", Contained = true, LazyLoad = true)]
        [SerializationIgnore]
        T_Consumer[] Consumers
        {
            get;
            set;
        }
我现在用GridView来显示Consumer的内容,不过City_ID是无意义的外键,想显示对应City_Name,是不是一定要建视图类?这样的话, 如果表比较多的话,视图类会很多,而且不好控制,有没有什么方法,使得City_ID
与City_Name关联起来?


    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.
寻路者  
View profile  
 More options Dec 15 2006, 12:07 am
From: "寻路者" <181443...@qq.com>
Date: Thu, 14 Dec 2006 21:07:59 -0800
Local: Fri, Dec 15 2006 12:07 am
Subject: 使用GridView时的问题
例如我有2个实体
public interface T_City:Entity
    {

        [PrimaryKey]
        string City_ID
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        [NotNull]
        string City_Name
        {
            get;
            set;
        }

        [SqlType("nvarchar(16)")]
        [NotNull]
        string Province_Name
        {
            get;
            set;
        }

        [SqlType("nvarchar(256)")]
        string Explain
        {
            get;
            set;
        }

        [FkQuery("City_ID", Contained = true, LazyLoad = true)]
        [SerializationIgnore]
        V_Consumer[] Vconsumers
        {
            get;
        }
    }
public interface T_Consumer:Entity
    {

        [PrimaryKey]
        string Consumer_ID
        {
            get;
            set;
        }

        [NotNull]
        string PWD
        {
            get;
            set;
        }

        [SqlType("nvarchar(2)")]
        string Sex
        {
            get;
            set;
        }

        string City_ID
        {
            get;
            set;
        }
    }
我现在用GridView来显示Consumer,其中
City_ID只是外键,它的值没什么意义,我想显示CIty_Name,这样是不是一定要建个视图实体?如果是的话,在表多的情况下,会需要很多视图,很不方 便的,有什么好解决方法么?


    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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 15 2006, 1:19 am
From: "寻路者" <181443...@qq.com>
Date: Thu, 14 Dec 2006 22:19:49 -0800
Local: Fri, Dec 15 2006 1:19 am
Subject: Re: 使用GridView时的问题
不好意思,一下子连发了

    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 15 2006, 1:29 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 15 Dec 2006 14:29:20 +0800
Local: Fri, Dec 15 2006 1:29 am
Subject: Re: 使用GridView时的问题

可以将City_ID改为一个City实体。然后为Consumer写一个partial
class,添加一个CityName属性,简单返回Consumer的City实体的Name属性。

On 12/15/06, 寻路者 <181443...@qq.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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 15 2006, 1:32 am
From: "寻路者" <181443...@qq.com>
Date: Thu, 14 Dec 2006 22:32:15 -0800
Local: Fri, Dec 15 2006 1:32 am
Subject: Re: 使用GridView时的问题
能简单写下代码么?看的不是很明白

    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 15 2006, 1:42 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 15 Dec 2006 14:42:00 +0800
Subject: Re: 使用GridView时的问题

把City_ID属性改为:

       [FkReverseQuery]
       CityCity
       {
           get;
           set;
       }

然后在你的Entities所在的project建一个独立的Comsumer.cs文件,包含下面的内容:

namespace YourNamespace
{
  public partial class Comsumer : NBear.Common.Entity
  {
    public string CityName { get { if (City != null) return
City.City_Nameelse return null; } }
  }

}

On 12/15/06, 寻路者 <181443...@qq.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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 19 2006, 10:40 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 19 Dec 2006 19:40:13 -0800
Local: Tues, Dec 19 2006 10:40 pm
Subject: Re: 使用GridView时的问题
用了这个我怎么添加Consumer的City_ID?

    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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 19 2006, 10:52 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 19 Dec 2006 19:52:42 -0800
Local: Tues, Dec 19 2006 10:52 pm
Subject: Re: 使用GridView时的问题
我在添加City_ID时发现Consumer里没有CIty_ID只有City,而在对Consumer.City.City_ID付值时出现:未将对象引用 设置到对象的实例
这样的错误提示.

    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 19 2006, 10:55 pm
From: Teddy <shijie...@gmail.com>
Date: Wed, 20 Dec 2006 11:55:25 +0800
Local: Tues, Dec 19 2006 10:55 pm
Subject: Re: 使用GridView时的问题

你可以new一个City,设置city.City_ID=id再comsumer.City = city;

On 12/20/06, 寻路者 <181443...@qq.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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 19 2006, 11:07 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 19 Dec 2006 20:07:01 -0800
Local: Tues, Dec 19 2006 11:07 pm
Subject: Re: 使用GridView时的问题
这样会不会增加数据库的压力?

    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 19 2006, 11:10 pm
From: Teddy <shijie...@gmail.com>
Date: Wed, 20 Dec 2006 12:10:18 +0800
Local: Tues, Dec 19 2006 11:10 pm
Subject: Re: 使用GridView时的问题

使用City代替CityID时,取Comsumer.City数据自然要多查一次数据库的。所以要根据实际情况来取舍。

On 12/20/06, 寻路者 <181443...@qq.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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 19 2006, 11:33 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 19 Dec 2006 20:33:42 -0800
Local: Tues, Dec 19 2006 11:33 pm
Subject: Re: 使用GridView时的问题
而且这样改了,我发现删除和添加会很麻烦.实在不好取舍.

    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 19 2006, 11:40 pm
From: Teddy <shijie...@gmail.com>
Date: Wed, 20 Dec 2006 12:40:09 +0800
Local: Tues, Dec 19 2006 11:40 pm
Subject: Re: 使用GridView时的问题

还有一个办法是在保留City_ID的情况下,为 Comsumer增加一个
CustomQuery的City属性,这样能既保留City_ID操作的方便性,又能获得查询City的便利:

//CustomQuery的第一个参数的意思是:City实体的City_ID属性(由{City_ID}表示)的值等于当前Comsumer实例的City _ID属性(由@City_ID表示)的值。
[CustomQuery("{City_ID} = @City_ID")]
City { get; set; }

Teddy

On 12/20/06, 寻路者 <181443...@qq.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.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 19 2006, 11:51 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 19 Dec 2006 20:51:32 -0800
Local: Tues, Dec 19 2006 11:51 pm
Subject: Re: 使用GridView时的问题
好的,我去试一下

    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