我有一个带有嵌套类的 Dto 类,我用它来将模型绑定到我的视图。嵌套类有一个id属性需要传递回我的应用程序服务,但到目前为止我得到null
我尝试过的一些事情是
<input asp-for="StoreWalk.Department.Id" type="hidden" />
@Html.HiddenFor(h => h.StoreWalk.Department.Id)
<input type="hidden" name="version" value="@Model.StoreWalk.Version" />
<input type="hidden" name="department.id" value="@Model.StoreWalk.Department.Id" />
<input type="hidden" name="department_id" value="@Model.StoreWalk.Department.Id" />
<input type="hidden" id="StoreWalk_Department_Id" name="department_id" value="@Model.StoreWalk.Department.Id" />
Run Code Online (Sandbox Code Playgroud)
我的模特班
public class CreateOrEditStoreWalkViewModel
{
public CreateOrEditStoreWalkDto StoreWalk { get; set; }
public bool IsEditMode => StoreWalk.Id.HasValue;
}
public class CreateOrEditStoreWalkDto : EntityDto<int?>
{
// Id property is implemented in `EntityDto` as int?
[Required]
public string Store { get; set; }
public string Comments { …Run Code Online (Sandbox Code Playgroud) 对于 codable 新手,我尝试使用 codable 为 alamofire 创建一个类,并尝试发出 api 请求。我收到一些 Swift.DecodingError.typeMismatch 错误,并且由于我的模型类而发现了它。现在我需要的是在解码之前以 JSON(String) 格式打印 alamofire 响应,以便我可以识别 typeMismatch
static func performRequest<T:Decodable>(route:APIRouter, decoder: JSONDecoder = JSONDecoder(), completion:@escaping (Result<T,Error>)->Void) -> DataRequest {
return AF.request(route)
.responseDecodable (decoder: decoder){ (response: DataResponse<T>) in
print(response.result)
completion(response.result)
}
}
Run Code Online (Sandbox Code Playgroud)
我想要一些代码来打印 alamofire 的实际结果