[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是个无意义的主键值,是不是必须要建个视图实体才行?有没有好的方法,因为如果建视图的话,在表多的话会很多.
DateTime Birthday
{
get;
set;
}
string City_ID
{
get;
set;
}
}
public interface T_City:Entity
{
我现在用GridView来显示Consumer的内容,不过City_ID是无意义的外键,想显示对应City_Name,是不是一定要建视图类?这样的话,如果表比较多的话,视图类会很多,而且不好控制,有没有什么方法,使得City_ID
与City_Name关联起来?
[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,这样是不是一定要建个视图实体?如果是的话,在表多的情况下,会需要很多视图,很不方便的,有什么好解决方法么?
不好意思,一下子连发了
能简单写下代码么?看的不是很明白
我在添加City_ID时发现Consumer里没有CIty_ID只有City,而在对Consumer.City.City_ID付值时出现:未将对象引用设置到对象的实例
这样的错误提示.
这样会不会增加数据库的压力?
而且这样改了,我发现删除和添加会很麻烦.实在不好取舍.