/// <summary> /// Create a new WebProduct object. /// </summary> /// <param name="productId">Initial value of the ProductId property.</param> /// <param name="name">Initial value of the Name property.</param> public static WebProduct CreateWebProduct(global::System.Int32 productId, global::System.String name) { WebProduct webProduct = new WebProduct(); webProduct.ProductId = productId; webProduct.Name = name; return(webProduct); }
static void RunExample() { using (var context = new EFRecipesEntities()) { var w1 = new WebProduct { Name = "Camping Tent", Description = "Family Camping Tent, Color Green" }; var w2 = new WebProduct { Name = "Chemical Light" }; var w3 = new WebProduct { Name = "Ground Cover", Description = "Blue ground cover" }; context.WebProducts.AddObject(w1); context.WebProducts.AddObject(w2); context.WebProducts.AddObject(w3); context.SaveChanges(); } using (var context = new EFRecipesEntities()) { Console.WriteLine("Query using eSql..."); var esql = @"select value EFRecipesModel.Store.ISNULL(p.Description,p.Name) from EFRecipesEntities.WebProducts as p"; var prods = context.CreateQuery <string>(esql); foreach (var prod in prods) { Console.WriteLine("Product Description: {0}", prod); } } using (var context = new EFRecipesEntities()) { Console.WriteLine(); Console.WriteLine("Query using LINQ..."); var prods = from p in context.WebProducts select BuiltinFunctions.ISNULL(p.Description, p.Name); foreach (var prod in prods) { Console.WriteLine(prod); } } Console.WriteLine("Press <enter> to continue..."); Console.ReadLine(); }
/// <summary> /// Deprecated Method for adding a new object to the WebProducts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToWebProducts(WebProduct webProduct) { base.AddObject("WebProducts", webProduct); }