1
私は、次のクラスがあります。MVCのviewModelからモデルを取り込むための推奨される方法は何ですか?
public class City {
public string key1 {get; set; }
public string key2 { get; set; }
public string col1 { get; set; }
public string col2 { get; set; }
public int newplusnew2 { get; set; }
}
のviewmodel:
public class CityViewModel {
public City city { get; set; }
public int new1 { get; set; }
public int new1 { get; set; }
}
アクション:
public JsonResult JsonCreate(CityViewModel viewModel)
{
// Validation checks go here
var model = new City();
???
}
私は4つの文字列を移入するために誰かが私に最善の方法を教えてもらえますビューモデルからのint列?これを行うための推奨される方法がある場合は、 を知りたいだけです。
ポストバックから 'CityViewModel'を取得し、' City out'を取得する必要がありますが、 'CityViewModel'には'あなたは 'City model = viewModel.city'を実行することができます – themarcuz
他の返信を見ることができないので、私は答えとしてそれを入れます。 – themarcuz
はい、してください。どうもありがとう。 –