私はコアが.netのmvcアプリケーションを作っていますが、私は立ち往生しています。私のバックオフィスでは、GUIDの問題のため削除に問題があります。私の変数 'モデルは、' 問題を与える:暗黙のうちにBaseEntityに変換できません<System.Guid>
暗黙のうちに 'Overnight.Models.BaseEntity' 私のRoleController.csで
コードに型 'Overnight.Models.Security.ApplicationRole' を変換できません:
[HttpGet("[area]/[controller]/[action]/{id:Guid}")]
public async Task<IActionResult> Delete(Guid id, [FromQuery] ActionType actionType)
{
var model = await ApplicationDbContext.Roles.FirstOrDefaultAsync(m => m.Id == id);
if(model == null)
{
return RedirectToAction("Index");
}
var viewModel = new ActionRoleViewModel()
{
//error: Cannot implicitly convert type 'Overnight.Models.Security.ApplicationRole' to 'Overnight.Models.BaseEntity<System.Guid>'
BaseEntity = model,
ActionType = actionType
};
return View(viewModel);
}
これは私のBaseEntity.csです:
namespace Overnight.Models
{
public class BaseEntity<T> : IBaseEntity<T>
{
public T Id { get; set; }
public DateTime CreatedAt { get; set; }
public Nullable<DateTime> UpdatedAt { get; set; }
public Nullable<DateTime> DeletedAt { get; set; }
}
}
は、これが私のActionRoleViewModel.csです:
namespace Overnight.Models.ViewModels
{
public class ActionRoleViewModel : ActionBaseEntityViewModel<Guid>
{
}
}
これは私のApplicationRole.csです:
namespace Overnight.Models.Security
{
public class ApplicationRole : IdentityRole<Guid>
{
public DateTime CreatedAt {get; set;}
public Nullable<DateTime> UpdatedAt {get; set;}
public Nullable<DateTime> DeletedAt {get; set;}
}
}
私は私が代わりにTのGUIDを置くが、私は同じエラーに
EDIT持つ保つ異なるBaseEntities作ってみました:
をこれは私のActionBaseEntityViewModel.csです:
namespace Overnight.Models.ViewModels
{
public class ActionBaseEntityViewModel<T>: ActionViewModel
{
public BaseEntity<T> BaseEntity { get; set; }
}
}
'ActionBaseEntityViewModel'の定義は何ですか? – Dai
お返事ありがとうございます。 – hxwtch
'IdentityRole'の定義は何ですか? –
Dai