예제 #1
0
        public IEnumerable <Movie> ToList()
        {
            using (var conn = new SqlConnection(_ConnectionString))
            {
                conn.Open();
                var helper = new DbHelperSql(conn);

                string sql  = @"
select  ID, Genre, Price, ReleaseDate, Title
from    Movie
";
                var    dt   = helper.ExecDataTableSql(sql);
                var    list = dt.AsEnumerable().Select(dr => new Movie()
                {
                    Id          = (int)dr["ID"],
                    Genre       = (string)dr["Genre"],
                    Price       = (decimal)dr["Price"],
                    ReleaseDate = (DateTime)dr["ReleaseDate"],
                    Title       = (string)dr["Title"],
                });
                return(list);
            }
        }