数据抓取链接数据库查询的sql语句
1》链接的是sql server库时(变量前面加'@'):
public AqiSchedule LoadByCode(string code)
{
string query =
$"select * from {SqlGenerator.TableName} where CODE = @Code ";
return Connection.Query<AqiSchedule>(query, new { Code = code }).FirstOrDefault();
}
2》链接的是oral库时(变量前面加':'):
public IEnumerable<AirQualityHour> LoadByPointCode(string pointCode, DateTime startTime)
{
string query =
$"select * from {SqlGenerator.TableName} where STATIONCODE = :pointCode and MONIDATE > :startTime";
return _connection.Query<AirQualityHour>(query,
new
{
pointCode = pointCode,
startTime = startTime
});
}