Пример #1
0
        /// <summary>
        /// LINQ to show all cars in the data grid
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            var db = new CarsDBEntities();

            var query = (from car in db.CarsTables
                         select car).ToList();

            GridAll.DataSource = query;
            GridAll.DataBind();
        }
Пример #2
0
        /// <summary>
        /// Linq for black cars and in the datagrid
        /// it will show only black cars
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            CarsDBEntities db = new CarsDBEntities();

            var query = (from car in db.CarsTables
                         where car.color == "Black"
                         select car).ToList();

            GridBlack.DataSource = query;
            GridBlack.DataBind();
        }