i'm using Simple.Data and I have a question about.
I have the following classes:
public abstract class User
{
public int Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Salt { get; set; }
}
public class Customer : User
{
public string Email { get; set; }
}
public class Admin : User
{
public string Name { get; set; }
public bool IsActive{ get; set; }
}
And a class that makes the actions in database:
public class Manager
{
public string ConString { get; set; }
public Manager()
{
ConString = ConfigurationManager.ConnectionStrings["Test"].ConnectionString;
}
public void CustomerUpdate()
{
var obj = new Customer()
{
Id = 1,
Username = "teste",
Password = "teste",
Salt = "",
Email = "teste@teste.com"
};
var db = Database.OpenConnection(conString);
db.tbCustomer.Update(obj);
}
public void AdminUpdate()
{
var obj = new Admin()
{
Id = 1,
Username = "teste",
Password = "teste",
Salt = "",
Name = "teste",
IsActive = true
};
var db = Database.OpenConnection(conString);
db.tbAdmin.Update(obj);
}
}
But, i have a problem:
In my db, in the table tbCustomer, the Primary Key is the "CustomerId" column. And the Primary Key of the table tbAdmin is the "AdminId" column. As the User class has a property called "Id", I can not do updates.
Is there any way I map for when you're giving update on tbCustomer table, the system take "Id" property and enter the "CustomerId" column? Same for tbAdmin. I want him to take "Id" and place in "AdminId".