Ejemplo n.º 1
0
        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"]));
            }));
        }
Ejemplo n.º 2
0
        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"]));
            }));
        }