モデル:
public class Student
{
public int StudentID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Gender Gender { get; set; }
public string Address { get; set; }
}
DB コンテキスト:
public class MyContext : DbContext
{
public MyContext():base(connectionstring)
{
}
public DbSet<Student> Student { get; set; }
}
ラッパー クラス:
public class StudentWrapper
{
public int StudentID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Gender Gender { get; set; }
public string Address { get; set; }
}
実装:
public void AddStudent()
{
using(MyContext ctx = new MyContext())
{
StudentWrapper newStudent = new StudentWrapper(); // If ever I wanted this `working`
ctx.Student.Add(newStudent);
}
}
CRUD 操作でモデルを直接使用するのではなく、モデル クラスのラッパーを作成したいのですが、そうする権利がありますか?