Пример #1
0
 public int Insert(Teg teg)
 {
     using (var db = dbFactory.Open())
     {
         long id = db.Insert(teg, selectIdentity: true);
         return(Convert.ToInt32(id));
     }
 }
Пример #2
0
        public int Insert(string teg)
        {
            using (var db = dbFactory.Open())
            {
                Teg t = new Teg
                {
                    Name = teg
                };

                var single = db.Single <Teg>(x => x.Name == teg);
                if (single == null)
                {
                    long id = db.Insert <Teg>(t, selectIdentity: true);
                    return(Convert.ToInt32(id));
                }
                else
                {
                    return(single.Teg_Id);
                }
            }
        }