using Dapper; using dccdc.Models; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace dccdc.DAL { public class sqdyDal { public List GetListByType(string type) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { return conn.Query("select * from sqdy where 1=1 and type=@type", new { @type = type }).ToList(); } } public string Add(sqdyModel model) { using (IDbConnection conn = CommHelper.GetSqlConnection()) { var result = conn.Query("select * from sqdy where 1=1 and type=@type and hblx=@hblx and hbid=@hbid", new { @type = model.type, @hblx = model.hblx, @hbid = model.hbid }).ToList(); if (result == null || result.Count == 0) { string sql = @"INSERT INTO [dccdc].[dbo].[sqdy] ([type] ,[hblx] ,[hbid]) VALUES (@type ,@hblx ,@hbid)"; var result2 = conn.Execute(sql, model); return result2.ToString(); } else return "1"; } } } }