Exemplo n.º 1
0
 public static int Create(Task.Models.Person person)
 {
     using (IDbConnection db = new SqlConnection(connectionString))
     {
         var sqlQuery    = "insert into Person (LastName, FirstName, MiddleName) values(@LastName, @FirstName, @MiddleName); select cast(SCOPE_IDENTITY() as int)";
         int newPersonId = db.Query <int>(sqlQuery, person).FirstOrDefault();
         return(newPersonId);
     }
 }
Exemplo n.º 2
0
 public static void InitData()
 {
     Task.Models.Person fahaPerson = new Task.Models.Person();
     fahaPerson.LastName   = "Faridun";
     fahaPerson.FirstName  = "Berdiev";
     fahaPerson.MiddleName = "Hasanovich";
     Task.Models.Person mjonPerson = new Task.Models.Person();
     mjonPerson.LastName   = "Mijgona";
     mjonPerson.FirstName  = "Jumaeva";
     mjonPerson.MiddleName = "Shohinovna";
     Task.Models.Person jofiPerson = new Task.Models.Person();
     jofiPerson.LastName   = "Firuz";
     jofiPerson.FirstName  = "Jonmamadov";
     jofiPerson.MiddleName = "Raimovich";
     PersonContext.Create(fahaPerson);
     PersonContext.Create(mjonPerson);
     PersonContext.Create(jofiPerson);
 }