コード例 #1
0
ファイル: ProductRepository.cs プロジェクト: pkcool/testrepo
 /// <summary>
 /// IQueryable of all Products
 /// </summary>
 /// <returns></returns>
 public IQueryable<Product> GetProducts()
 {
     var dataContext = new NorthwindEntities();
     var products = from p in dataContext.Products
                    select p;
     return products;
 }
コード例 #2
0
        public void Fill()
        {
            var dataContext = new NorthwindEntities();

            Categories = dataContext
                            .Categories
                            .Select(a =>
                                new
                                {
                                    a.CategoryName,
                                    a.CategoryID
                                }
                            )
                            .ToList()
                            .Select(a =>
                                new SelectListItem
                                {
                                    Text = a.CategoryName,
                                    Value = a.CategoryID.ToString(),
                                    Selected = a.CategoryID == SelectedCategoryID
                                }).ToList();

            Suppliers = dataContext
                            .Suppliers.
                            Select(a =>
                                new
                                {
                                    a.CompanyName,
                                    a.SupplierID
                                }
                            )
                            .ToList()
                            .Select(a =>
                               new SelectListItem
                               {
                                   Text = a.CompanyName,
                                   Value = Convert.ToString(a.SupplierID),
                                   Selected = a.SupplierID == SelectedSupplierID
                               }).ToList();
        }