コード例 #1
0
 public List<Product> ProductGetAll()
 {
     var db = new eBikesEntities();
     return (from f in db.Product
             join pic in db.Picture on f.PictureId equals pic.PictureId
             select new Product()
                             {
                                 Color = f.Color,
                                 Description = f.Description,
                                 ManufacturerId = f.ManufacturerId,
                                 Name = f.Name,
                                 PictureUrl = pic.Url,
                                 Price = f.Price,
                                 ProductId = f.ProductId
                             }).ToList();
 }
コード例 #2
0
        public Product ProductGetById(int productId)
        {
            var db = new eBikesEntities();

            return (from f in db.Product
                    where f.ProductId == productId
                    join pic in db.Picture on f.PictureId equals pic.PictureId
                    select new Product()
                    {
                        Color = f.Color,
                        Description = f.Description,
                        ManufacturerId = f.ManufacturerId,
                        Name = f.Name,
                        PictureUrl = pic.Url,
                        Price = f.Price,
                        ProductId = f.ProductId
                    }).FirstOrDefault();
        }