Database Reference
In-Depth Information
Figure 19-12. Displaying the PublishCurrency form
How It Works
Because you are working with an Entity Data Model, you do not need to deal with SqlConnection ,
SqlCommand , and so forth. Here you create an object referencing the EntityContainer named
AWCurrencyEntities , which refers to the entire connection string that is stored in the App.config file.
AWCurrencyEntities currContext = new AWCurrencyEntities();
After specifying the object to EntityContainer , it's time to loop through the object set that is
composed of EntityContainer.EntitySet , thus including the name of the EntityContainer object, which
represents the EntityContainer , suffixed with EntitySet .
Note The EntityContainer element is named after the database schema, and all “entity sets” that should be
logically grouped together are contained within an EntityContainer element. An EntitySet represents the
corresponding table in the database. You can explore the names of your EntityModel objects under the
ConceptualModel element of the .edmx file, as shown in Figure 19-10.
foreach (var cr in currContext.Currencies)
{
txtCurrency .AppendText(cr.ModifiedDate.ToString());
txtCurrency.AppendText("\t\t");
txtCurrency.AppendText(cr.CurrencyCode.ToString());
txtCurrency.AppendText("\t\t");
txtCurrency.AppendText(cr.Name.ToString());
 
 
Search WWH ::




Custom Search