Database Reference
In-Depth Information
Listing 11-13. The Definition of the PlatinumSponsors() Function
<Function Name="PlatinumSponsors">
<ReturnType>
<CollectionType>
<ReferenceType Type="EFRecipesModel.Sponsor" />
</CollectionType>
</ReturnType>
<DefiningExpression>
select value ref(s)
from EFRecipesEntities.Sponsors as s
where s.SponsorType.Description == 'Platinum'
</DefiningExpression>
</Function>
3.
Insert into and query the model using code similar to the pattern shown in Listing 11-14.
Listing 11-14. Using eSQL and Our PlatinumSponsors() Function to Find All Events
with Platinum-Level Sponsors
class Program
{
static void Main(string[] args)
{
RunExample();
}
static void RunExample()
{
using (var context = new EFRecipesEntities())
{
var platst = new SponsorType { Description = "Platinum" };
var goldst = new SponsorType { Description = "Gold" };
var sp1 = new Sponsor
{
Name = "Rex's Auto Body Shop",
SponsorType = goldst
};
var sp2 = new Sponsor
{
Name = "Midtown Eye Care Center",
SponsorType = platst
};
var sp3 = new Sponsor
{
Name = "Tri-Cities Ford",
SponsorType = platst
};
var ev1 = new Event { Name = "OctoberFest", Sponsor = sp1 };
var ev2 = new Event { Name = "Concerts in the Park", Sponsor = sp2 };
var ev3 = new Event { Name = "11th Street Art Festival", Sponsor = sp3 };
context.Events.Add(ev1);
context.Events.Add(ev2);
 
Search WWH ::




Custom Search