TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lisen
NA
63
1.6k
model and repository in C#
Nov 29 2018 6:05 AM
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);
}
}
Reply
Answers (
4
)
Generate new id code with alpha and number format
Navigate Records in WinForm C#