protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Beer b = new PremiumBeer(); b.Name = "Primator"; b.Weight = b.InitialWeight = 645; b.Country = "CZECH"; using (TweetBeerContainer dbContainer = new TweetBeerContainer()) { #region Inserting dbContainer.AddToBeer(b); dbContainer.SaveChanges(); #endregion #region Updating b.Name = "Corona"; dbContainer.SaveChanges(); #endregion #region Delete //dbContainer.DeleteObject(b); //dbContainer.SaveChanges(); #endregion #region LINQ Query var coronas = from beer in dbContainer.Beer.ToList() where beer.Name == "Corona" select beer; #endregion } #region Equivalent to using //TweetBeerContainer v = null; //try //{ // v = new TweetBeerContainer(); // // Fazer um monte de coisa //} //catch //{ //} //finally //{ // v.Dispose(); //} #endregion } }
/// <summary> /// Create a new PremiumBeer object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="country">Initial value of the Country property.</param> /// <param name="weight">Initial value of the Weight property.</param> /// <param name="initialWeight">Initial value of the InitialWeight property.</param> public static PremiumBeer CreatePremiumBeer(global::System.Int64 id, global::System.String name, global::System.String country, global::System.Double weight, global::System.Double initialWeight) { PremiumBeer premiumBeer = new PremiumBeer(); premiumBeer.Id = id; premiumBeer.Name = name; premiumBeer.Country = country; premiumBeer.Weight = weight; premiumBeer.InitialWeight = initialWeight; return(premiumBeer); }
/// <summary> /// Create a new PremiumBeer object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="country">Initial value of the Country property.</param> /// <param name="weight">Initial value of the Weight property.</param> /// <param name="initialWeight">Initial value of the InitialWeight property.</param> public static PremiumBeer CreatePremiumBeer(global::System.Int64 id, global::System.String name, global::System.String country, global::System.Double weight, global::System.Double initialWeight) { PremiumBeer premiumBeer = new PremiumBeer(); premiumBeer.Id = id; premiumBeer.Name = name; premiumBeer.Country = country; premiumBeer.Weight = weight; premiumBeer.InitialWeight = initialWeight; return premiumBeer; }