public int Insert(Teg teg) { using (var db = dbFactory.Open()) { long id = db.Insert(teg, selectIdentity: true); return(Convert.ToInt32(id)); } }
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); } } }