public IReadOnlyList <AreaEntity> GetData() { string sql = @" select AreaId, AreaName from Areas "; //return MSSqlHelper.Query<AreaEntity>(sql, CreateEntity); 省略できる return(MSSqlHelper.Query(sql, reader => { return new AreaEntity(Convert.ToInt32(reader["AreaId"]), Convert.ToString(reader["AreaName"])); })); }
public IReadOnlyList <WeatherEntity> GetData() { string sql = @" select A.AreaId, isnull(B.AreaName,'') as AreaName, A.DataDate, A.Condition, A.Temperature from Weather A left join Areas B on A.AreaId = B.AreaId "; return(MSSqlHelper.Query(sql, reader => { return new WeatherEntity( Convert.ToInt32(reader["AreaID"]), Convert.ToString(reader["AreaName"]), Convert.ToDateTime(reader["DataDate"]), Convert.ToInt32(reader["Condition"]), Convert.ToSingle(reader["Temperature"])); })); }