我想连接名字和姓氏,并在view.i中将其显示为fullname,因为当你再次生成edmx文件时,它将不会影响但是错误无法识别的字段,任何想法如何?
public partial class userdetail
{
public userdetail()
{
this.orderdetails = new HashSet<orderdetail>();
}
public string userid { get; set; }
public string username { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public virtual ICollection<orderdetail> orderdetails { get; set; }
}
我为验证创建了另一个类usermeta。
public class Usemeta
{
[Required]
public string userid { get; set; }
[Required]
public string username { get; set; }
[Required]
public string firstname { get; set; }
[Required]
public string lastname { get; set; }
//[Required]
//public string Fullname { get { return string.Concat(firstname + "" + lastname); } }
}
然后我创建了一个部分类。
[MetadataType(typeof(Usemeta))]
public partial class userdetail
{
}
答案 0 :(得分:3)
只需在View中添加另一个属性,并将FirstName和LastName连接为只读属性,如下所示:
public string FullName
{
get { return FirstName + " " +LastName ;}
}
答案 1 :(得分:1)
您也可以使用表达体:
exec