Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 模型绑定相关实体_C#_Asp.net_Null_Model Binding_Aspnetboilerplate - Fatal编程技术网

C# 模型绑定相关实体

C# 模型绑定相关实体,c#,asp.net,null,model-binding,aspnetboilerplate,C#,Asp.net,Null,Model Binding,Aspnetboilerplate,我正在尝试ASP.NET样板框架,我非常喜欢它,但还有很多东西需要学习。我无法使下面的案例起作用。 我有两个相关实体:Guest和SocialMedia CreateGuestViewModel如下所示: public class CreateGuestViewModel { public CreateSocialViewModel SocialMedia { get; set; } } 视图如下所示: public class CreateGuestViewModel { p

我正在尝试ASP.NET样板框架,我非常喜欢它,但还有很多东西需要学习。我无法使下面的案例起作用。 我有两个相关实体:
Guest
SocialMedia

CreateGuestViewModel
如下所示:

public class CreateGuestViewModel
{
    public CreateSocialViewModel SocialMedia { get; set; }
}
视图如下所示:

public class CreateGuestViewModel
{
    public CreateSocialViewModel SocialMedia { get; set; }
}

单击保存按钮后,在
guestapservice.Create
方法中,
SocialMedia
成员为
null

[AutoMapTo(typeof(Guest))]
public class CreateGuestInput
{
    public CreateSocialMediaInput SocialMedia { get; set; }
}

[AutoMapTo(typeof(SocialMedia))]
public class CreateSocialMediaInput
{
    public string Twitter { get; set; }
}
我肯定我错过了什么。你觉得怎么样

谢谢,
Marius

在html端,您使用
CreateGuestViewModel
CreateSocialViewModel
作为模型。但是在应用程序服务上,您绑定的是
CreateGuestInput
CreateSocialMediaInput
。模型必须相同