可以爲任何人的EDMX設計器類如何創建一個視圖模型和地圖的EDMX設計器類
想我的EDMX文件被命名爲School.edmx創建一個視圖模型提供了一個鏈接,它有school.Designer.cs類。 在設計器類我有如下因素實體對象
[EdmEntityTypeAttribute(NamespaceName="teamworkModel", Name="User")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class User : EntityObject
{
#region Primitive Properties
[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[DataMemberAttribute()]
public global::System.Int32 User_Pk
{
get
{
return _User_Pk;
}
set
{
if (_User_Pk != value)
{
OnUser_PkChanging(value);
ReportPropertyChanging("User_Pk");
_User_Pk = StructuralObject.SetValidValue(value);
ReportPropertyChanged("User_Pk");
OnUser_PkChanged();
}
}
}
private global::System.Int32 _User_Pk;
partial void OnUser_PkChanging(global::System.Int32 value);
partial void OnUser_PkChanged();
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
[Required(ErrorMessage="Please enter your name")]
[StringLength(20,ErrorMessage="Name cannot exceed 20 characters")]
[RegularExpression(@"^([a-zA-Z0-9 \.\&\'\-]+)$", ErrorMessage = "Invalid name")]
public global::System.String User_Name
{
get
{
return _User_Name;
}
set
{
OnUser_NameChanging(value);
ReportPropertyChanging("User_Name");
_User_Name = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("User_Name");
OnUser_NameChanged();
}
}
private global::System.String _User_Name;
partial void OnUser_NameChanging(global::System.String value);
partial void OnUser_NameChanged();
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
[Email(ErrorMessage="Invalid email address")]
[Required(ErrorMessage="Please enter email address")]
public global::System.String User_Mail_Id
{
get
{
return _User_Mail_Id;
}
set
{
OnUser_Mail_IdChanging(value);
ReportPropertyChanging("User_Mail_Id");
_User_Mail_Id = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("User_Mail_Id");
OnUser_Mail_IdChanged();
}
}
private global::System.String _User_Mail_Id;
partial void OnUser_Mail_IdChanging(global::System.String value);
partial void OnUser_Mail_IdChanged();
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
[Required(ErrorMessage="Please enter password")]
[StringLength(20,ErrorMessage="Password cannot exceed 20 characters")]
[RegularExpression(@"^([a-zA-Z0-9 \.\&\'\-]+)$", ErrorMessage = "Invalid password")]
public global::System.String User_Password
{
get
{
return _User_Password;
}
set
{
OnUser_PasswordChanging(value);
ReportPropertyChanging("User_Password");
_User_Password = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("User_Password");
OnUser_PasswordChanged();
}
}
private global::System.String _User_Password;
partial void OnUser_PasswordChanging(global::System.String value);
partial void OnUser_PasswordChanged();
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
public global::System.DateTime User_Creation_Date
{
get
{
return _User_Creation_Date;
}
set
{
OnUser_Creation_DateChanging(value);
ReportPropertyChanging("User_Creation_Date");
_User_Creation_Date = StructuralObject.SetValidValue(value);
ReportPropertyChanged("User_Creation_Date");
OnUser_Creation_DateChanged();
}
}
private global::System.DateTime _User_Creation_Date;
partial void OnUser_Creation_DateChanging(global::System.DateTime value);
partial void OnUser_Creation_DateChanged();
我在上述實體對象以下各列(用戶表)User_PK時,USER_NAME,USER_PASSWORD,USER_EMAIL_ID .....
請可以任何人都會建議如何爲包含除User_Password和User_Email_ID以外的所有以上列的上述實體對象創建視圖模型,因爲我需要將它用作我的view.I的強類型視圖模型。我還需要在具有選定列的同一viewmodel中使用另一個表....
我已經經歷了很多d ocuments..i已經花了1天半這個 任何人可以幫助.. 我知道這個問題的一再要求,但我cannt找到正確的方式做它... 感謝
謝謝,但我如何包括其他實體對象與選定的列在同一viewmodel..suppose我有項目表,其中我必須包括projectname和projectcreated日期列,我如何映射它... – bhargav 2011-12-21 11:11:17
我想我會有多個項目,所以我應該使用列表項目名稱。?並可以給你一個簡短的例子,使用映射我的情況 – bhargav 2011-12-21 11:19:08
var model = new User {User_Pk = userViewModel.Pk ....} var model2 = new Project {Name = userViewModel.Name ...} – heads5150 2011-12-21 11:23:19