public string GetNetPrice(string country, string gender, bool age) { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); ConnectionString = config.GetSection("Dapper").GetSection("Conn").Value; dbservice = new DapperDbService(ConnectionString); string data = String.Empty; try { var res = dbservice.Get <string>(@" EXEC [dbo].[GetNetPrice] @Country,@Gender, @age ", new { Country = country, Gender = gender, Age = age } ); data = res; } catch (Exception ex) { } return(data); }
public string GetCoveragePlanID(string country) { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); ConnectionString = config.GetSection("Dapper").GetSection("Conn").Value; dbservice = new DapperDbService(ConnectionString); string data = String.Empty; try { var res = dbservice.Get <string>(@" EXEC [dbo].[GetCoveragePlanId] @Country ", new { Country = country } ); data = res; } catch (Exception ex) { } return(data); }
public List <CustomerData> GetData() { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); ConnectionString = config.GetSection("Dapper").GetSection("Conn").Value; dbservice = new DapperDbService(ConnectionString); List <CustomerData> data = new List <CustomerData>(); try { var res = dbservice.GetList <CustomerData>(@" EXEC [dbo].[GetCustomerData] " ); data = (List <CustomerData>)res; } catch (Exception ex) { } return(data); }
/// <summary> /// 获取数据服务 /// </summary> /// <returns></returns> public static IDbService CreateConnection() { IDbService dbService = null; string orm = ConfigHelper.Configuration.GetSection("ORM").Value; string dbType = ConfigHelper.Configuration.GetSection("DbType").Value; string strConn = ConfigHelper.Configuration.GetConnectionString(string.Format("{0}:dev", dbType));; //获取配置进行转换 var dataBaseType = GetDataBaseType(dbType); switch (orm) { case "ZORM": dbService = new XROMService(strConn, dataBaseType); break; case "Dapper": dbService = new DapperDbService(strConn, dataBaseType); break; //case DatabaseType.MySql: // connection = new MySql.Data.MySqlClient.MySqlConnection(strConn); // break; //case DatabaseType.Npgsql: // connection = new Npgsql.NpgsqlConnection(strConn); // break; //case DatabaseType.Sqlite: // connection = new SQLiteConnection(strConn); // break; //case DatabaseType.Oracle: // connection = new Oracle.ManagedDataAccess.Client.OracleConnection(strConn); // break; //case DatabaseType.DB2: // break; } return(dbService); }