Hi,
i am working in a C# project using model and repository..
im not sure if im using the method correctly or not because im new in C# programming
i am adding some code in below.. pls tell me if im using it correctly or not..
for me its working fine..
but i want to use with begin,commit and rollback
pls help me in this matter
models.cs
- namespace sample.Models
- {
- class Model_Sample
- {
- public string Database { get; set; }
- public string ServerInstance { get; set; }
- public string UserID { get; set; }
- public string Password { get; set; }
- }
- class Model_Customer
- {
- public int CustomerID { get; set; }
- public string CustomerName { get; set; }
- public int age { get; set; }
- public string Phone { get; set; }
- }
- }
Repository.cs
- public List< Model_Customer > Customer(Model_Sample data, Model_Customer mCustomer)
- {
- IDbConnection db = new SqlConnection("Data Source=" + data.Instance + ";Initial Catalog=" + data.Database + ";User ID=" + data.UserID + ";Password=" + data.Password + "");
- List<Model_Customer> list = db.Query<Model_Customer>("ProcCustomerCRUD", mCustomer,
- commandType: CommandType.StoredProcedure).ToList<Model_Customer>();
- return list;
windows form
- public partial class frmCustomerMaster : Form
- {
- Model_Sample data= new Model_Sample ();
- Model_Customer mycustomer = new Model_Customer();
- private void BtnSave_Click(object sender, EventArgs e)
- {
- mycustomer.CustomerID = Convert.ToInt32(txtcustomerID.text);
- mycustomer.CustomerName = txtCustomerName.text
- mycustomer.age = Convert.ToInt32(txtage.text);
- mycustomer.phone = txtphone.Text;
- rep.Customer(data, mycustomer);
- }
- }