Entity Framework and LINQ Presentation
Wednesday, May 21 2008 - entity-framework, ado-net, linq, ineta - 0 comments
I had a great time at the INETA sponsored combined Sarasota SQL Server and Sarasota .NET User groups' meeting last Wednesday evening. I presented the Entity Framework and LINQ using the latest bits, which came out 2 days prior to the presentation. It made for some interesting moments as I barely had enough time to convert all of my demos over to the latest bits. Yeah, I know, I should have just went with the old bits, but the smart me was sleeping and the bold me took the wheel :)
I've attached my slide deck and some demo code that I used for the presentation. The code has been converted to work with the Visual Studio and .NET 3.5 SP 1 beta bits. Everything is "as is" as some of the demo code I wrote on the fly at the presentation.
There were about 40 people there for the presentation and it was a very lively and interactive group. A lot of good questions were posed and thought he flow was pretty fast it seemed to be well received.
Need a "WHERE field IN (x, y, z)" Clause with LINQ
Tuesday, May 20 2008 - sql, linq - 2 comments
A colleague and I were talking about some LINQ features yesterday and one of the topics that came up was how to implement an IN clause. Ya know, similar to how SQL statements can use an IN clause in the WHERE clause like this:
SELECT city FROM Customers WHERE state IN ('FL', 'NY'', 'NC')
Then I remembered Dan Wahlin's post on a similar topic where he shows the following solution (from Dan's post):
The code uses the Contains() method to search for a specific ProductID within the collection which ends up creating a WHERE IN type query. You can do the same thing with LINQ:
public static Product[] GetProducts(Guid[] prodIDs)
{
return (from p in GetProducts()
where prodIDs.Contains(p.ProductID)
select p).ToArray<Product>();
}
The idea here is that the LINQ query is written normally (meaning the from and the select clauses reference the objects). Then the where clause in the LINQ query operates on an array of values. The array of values contains the values you would put in the IN clause. The array supports standard query operators so you can use the Contains method on the array and pass in the value you want to look for.
Entity Framework & LINQ in Miramar, FL
Monday, May 19 2008 - entity-framework, linq - 0 comments
I'll be heading to Miramar, FL on July 8th for the local .NET User Group meeting to speak to the group about the Entity Framework and LINQ. I "hope" the final bits are released by then, but not on July 8th, please (yikes!). I went through a major overhaul of my demonstrations last week when the latest beta bits were released and it was the day before my last presentation on LINQ and the Entity Framework. It went well, but it was a bit too much "last minute" for me. Especially when I am spending every free moment writing my Silverlight book and its examples.
There is a lot to demonstrate .... showing why it exists, how it works, how to use it with a real world application. There are also the discussions of where it is heading, when to use it, when not to use it, and how it compares to existing tools. I often get asked "should I use EF in my app?". The answer always depends of course. But I generally do not encourage people to rip out their existing architecture and replace it with anything unless there is a major benefit that you can receive. The EF is a great tool, no doubt, but it still does not support certain aspects that would make it great (i.e. POCO). Can EF be everything to everyone? No, certainly not. Can EF be a valuable piece of your architecture? Absolutely. Would I jump up and down continuously for a week if they made it work with POCO? HECK YES!
Anyway ... its a good topic and always stirs up a good discussion, which is why I love talking about it. Its not about the model and its not about the data. Its about both, together.
If you are going to be in the area, please stop by. Should be a good discussion in South Florida! Here is the registration link.
Silverlight Consuming REST Services
Friday, May 16 2008 - silverlight, rest, linq, xml, wcf, book - 3 comments
I just finished writing the first draft of a sample I am including in my upcoming book tentatively titled Data Access with Silverlight 2 by O'Reilly. Without giving too much away yet since the final details of the contract are not set in stone, the application example consumes a REST service, manipulates it through LINQ to XML, and binds it to various controls and some composite controls. The interaction with the REST (REpresentational State Transfer) services is pretty slick and quite easy when using Silverlight and LINQ to XML. Of course there are always issues to deal with, but overall it works very nicely.
Why use REST? Well, REST services are becoming more abundant on the web. They do not expose a contract like WCF so when you deal with this type of data you can parse the XML using LINQ to XML or some other XML tools (though LINQ TO XML is so smooth why bother with anything else in this case). So this raw XML comes barreling into your Silverlight application asynchronously, LINQ to XML makes it fall in line, and its bound to where it needs to go via XAML.
Sending data back via REST is also very cool. I've got that working now too. I have to be careful not to go overboard fine tuning the examples though or the book will never get written :) Interacting with REST from Silverlight applications is just one piece of the data access puzzle, but its pretty cool.

Visual Studio 2008 and .NET 3.5 SP 1 Beta Download
Monday, May 12 2008 - visual-studio, net, entity-framework, linq, sql-server, astoria - 1 comments
Soma announced this morning that Visual Studio 2008 and .NET 3.5 SP 1 is now ready and can be downloaded. This includes several updates, includes support for SQL Server 2008, and has a few new products including the Entity Framework, LINQ to Entities and ADO.NET Data Services (aka Astoria). ScottGu posted some notes regarding what's included in the service pack, as well.
Of course all of this is released 2 days before I have a demonstration on the Entity Framework and LINQ to Entities on Wednesday to the Sarasota .NET and SQL Server User groups. So I have a few modifications to make for my presentations.
I received an error when I first tried to install it. The problem was that the service pack was in conflict with Silverlight Tools Beta for Visual Studio 2008 which I was using to create/edit Silverlight 2 applications. Once uninstalling this i was able to get the service pack to install properly. Scott Gu's post discusses this issue as well as the importance of making sure you install Vista SP 1 first.
Check out ScottGu's post for full details.
Silverlight, WCF and LINQ to SQL
Wednesday, May 07 2008 - silverlight, entity-framework, linq, sql, wcf - 1 comments
I've had some requests lately to write some articles that work with LINQ to SQL. I've ben focusing on the Entity Framework a lot due to its vast nature and that fact that its still relatively unknown to many people. So I am going to work on a LINQ to SQL project that ties into a multi tier model. I am also going to show how this can be hooked into a Silverlight 2 UI that connects through WCF to the lower layers.
I'll probably be demonstrating these first at an event I am trying to set up with Joe Healy of Microsoft in Tampa this coming August. The demos will be ready way before then, but I wanted to have some cool materials for this event. There is no title nor date yet, but once the event is set I will be sure to let blog about it. It should be a great day overall.
I also plan on giving some love to the Entity Framework, regular persistence/mapper models, MVP patterns and more. I just have to find a way to work it all in and still give enough to each topic. Of course, this means all demos are subject to change, but the content will be fresh and cool for certain.
Here is a very poorly and quickly thrown together diagram of one of the demos I am tweaking.
Entity Framework Q&A - Lazy Loading, ObjectContext, and LINQ
Monday, May 05 2008 - data-points, linq, entity-framework - 0 comments
I've received hundreds of questions regarding the Entity Framework and LINQ. Obviously developers are very interested in the Entity Framework and its data access and modeling implications.
I responded to some of the most frequently asked questions in the May 2008 Data Points column. Topic includes:
- Why use Entity SQL when I can use LINQ to get to entities?
- What is the role of ObjectContext?
- How do explicit and eager loading work LINQ and the Entity Framework?
- How do I see the SQL that will execute?
- What can I do with complex types?
- How do I create a complex type?
You can find my Data Points column in the May 2008 MSDN Magazine issue online.
Projecting with Aggregates in LINQ to Entities
Monday, April 28 2008 - linq, entity-framework, lambda - 1 comments
I'm all for quick and easy examples especially when it comes to LINQ, so here goes one that I get asked a lot. This is a quick example that shows how to grab a few properties from a parent entity and use an aggregate function on the parent entity's children entities. Specifically, this example grabs the OrderID and OrderDate from the Orders entity and then calculates the order total for each order. The sum is calculated by summing the UnitPrice * Quantity in the OrderDetails entity.
// Code below creates a projection containing LCDvar qry = from o in context.Orders where o.Customers.CustomerID == customerIDgroup o by o.OrderID into g
join o2 in context.Orders on g.Key equals o2.OrderID select new {OrderID = g.Key,
o2.OrderDate,
OrderTotal = o2.OrderDetails.Sum(d => d.UnitPrice * d.Quantity)
};
foreach (var orderInfo in qry)
{var msg = string.Format("OrderID={0}, OrderDate={1:d}, OrderTotal={2}",
orderInfo.OrderID, orderInfo.OrderDate, orderInfo.OrderTotal);
Console.WriteLine(msg);
}
Notice the grouping of the orders first. Then the Orders are joined back to the result so we can get the OrderDate property. Then the projection pulls out the Key (the OrderID), the OrderDate, and calculates the OrderTotal using an aggregate and a lambda expression.
Hopefully this will shed some light on this type of projection with LINQ for some.
JohnPapa.NET is Open for BusinRSS
Saturday, April 19 2008 - codebetter, graffiti, devconnections, entity-framework, ssrs, sql-server, linq - 0 comments
No that's not a typo in the title ... it's my poor attempt at dry humor :)
I have had several questions from people over the past few months regarding my noticeable sparseness in blogging at www.codebetter.com, my blogging home for the past 3 years. The truth is that it took me a while to get back to setting up my new blogging home at www.johnpapa.net . I used the various beta versions of Graffiti CMS to get it started and then I recently migrated the site over to the release version of Graffiti. I must say that Graffiti is perfect for my needs. I can consolidate my posts, organize my events, articles, and add some ASP.NET and SilverLight aspects, too.
So what will you find on www.johnpapa.net ? You will find my usual technical posts as well as a listing of all of the articles I have published (the books listing is not there yet) and all of the events I will be speaking at as they get scheduled and confirmed.
Will I still post to www.CodeBetter.com ? Yes, I will still cross post some content to www.CodeBetter.com but the superset of the posts will be on www.johnpapa.net including technical content, reviews, and opinions.
So please add my new site www.johnpapa.net to your aggregated feed list http://feeds.feedburner.com/JohnPapa.
I'll be at DevConnections this coming week in Orlando, so if you are going to be around please stop by one of my sessions on windows mobile development, LINQ, the Entity Framework or SQL Server Reporting Services and say hi!
Standard Query Operators with LINQ
Friday, April 04 2008 - entity-framework, linq, data-points, msdn - 0 comments
In the March issue of MSDN Magazine's Data Points column I explore a variety of the Standard Query Operators and how they work with LINQ. Here is a summary of the article:
In this month's column I will perform practical queries and operations with LINQ, using both LINQ to Objects and LINQ to Entities. I'll query a single collection of entities and dive deeper into a hierarchical set of entities using their navigation properties. I'll also show how you can apply many of the standard query operators to arrays and collections. I will demonstrate how LINQ's standard query operators are enhanced using lambda expressions and how they can let you parse specific information from a sequence and perform complex logic over a sequence.
You can check it out here.
Designing an Entity Data Model
Sunday, January 20 2008 - entity-framework, linq, data-points, edm - 0 comments
Just published is my article on Designing an Entity Data Model with the Entity Framework tools. This article is part of my Data Points column in the February issue of MSDN Magazine. A few months ago I wrote an article discussing an overview of the Entity Framework and examining the CSDL, SSDL, and MSL that defines the EDM. When that article was published the tools were not available, so in this article I decided to explain how the tools work which coincides nicely with the previous article's explanation of the XML files (CSDL, SSDL, MSL). The EDM designer sits on top of the XML files and uses the XML information to represent the model. Likewise, the model can be changed using the designer tools which then updates the XML under the covers.
I will be having a few more articles in the upcoming months that explain more about the Entity Framework and its auxiliary parts. For next month's issue I plan on going through many of the Standard Query Operators that can be used with LINQ to objects/entities. Also, if you are planning on attending DevConnections in Orlando in the Spring (this April), I will be presenting 2 different 1:15 minute sessions on the Entity Framework there as well.
As always, if you want to review my history of articles, please visit my articles history page where you can find them all listed.
New EF CTP! ADO.NET Entity Framework June 2007 CTP is Available
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 4 comments
The ADO.NET team has released the latest bits for the ADO.NET Entity Framework with the June 2007 CTP. There are samples on CodePlex, too. It claims many changes and support for a lot of new features ... I grabbed this partial list from their post:
- Changes in:
- Object Services
- Query
- Entity Client
- the Entity Data Model Wizard in Visual Studio
- no more default constructors in code-generated classes
- improvements to stored procedure support
- New Features:
- IPOCO
- detaching from long-running ObjectContext instances
- multiple entity sets per type
- support for referential integrity constraints
- span support
- transactions
- serialization
Notice the IPOCO support. This is something that is a step in the right direction for getting the entities in the EDM to move towards full POCO. I am downloading the bits now and can't wait to unwrap the candy!
Data Access "Practically Done"
Friday, February 01 2008 - net, ado-net, entity-framework, linq, ent-lib, sql - 3 comments
I will be kicking off my move to South Florida in a few weeks with a 1 day event for the “Practically Done” event series. On Wednesday August 1st and on Saturday August 4th I will be presenting “Data Access Done Right”, a full day event in Orlando.
Register here for Wednesday, August 1st – 9am to 5pm
Register here for Saturday, August 4th – 9am to 5pm
I encourage you to bring your laptops as code samples will be given out to all attendees at the beginning of the event. You can follow along with the samples as they are being discussed and demonstrated. Seating is limited for this event and discounts are available for early sign ups.
| "Practically Done" .NET Events | |
| Not everybody can take a week off from work to attend a technology conference that may be thousands of miles away and cost a fortune. Most of the time, those conferences cover technologies that won't be released for months or years, anyway. ASPSOFT recognizes the need for local, single day workshops that focus on current .NET technologies that you can apply to your projects today. "Practically Done" .NET Events feature:
Data Access Done Right Speaker: John Papa Location: Orlando, FL Data access is an integral component of an enterprise application’s architecture. Retrieving data, saving data, passing data between tiers, presenting data to a user interface, and managing transactions are all important pieces of a data access strategy. In this “Practically Done” workshop, Microsoft MVP John Papa will show you how to apply these techniques in your multi-tier applications today using Visual Studio 2005. The topics that will be covered in detail are:
| |
Entity Framework and its Tools in First Half of 2008
Friday, February 01 2008 - ado-net, entity-framework, linq - 2 comments
As I noted earlier, my latest article in MSDN Magazine was just posted a few days ago. If you visited it early on you might have missed the comment from the edtitor which reads:
[ Editor's Update - 6/19/2007: The ADO.NET Entity Framework and Tools will ship during the first half of 2008 as an update to the Visual Studio 2008 release.]
We were told the tools would ship later, so this just confirms the plans for the EF and its tools to be available next year. I'll be chomping at the bit to use it and giving as much feedback as I can to the team as I can. They seem dedicated to making a great product that we can use in DDD.
ADO.NET Entity Framework Overview
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 0 comments
My July 2007 Data Points column has been posted to the MSDN Magazine web site. This edition is titled "ADO.NET Entity Framework Overview".
I wrote this using the March CTP and then revised it using the Orcas Beta 1, so the code included works in the most recently available bits. Knowing that changes are on their way, I tried to focus the article on the concepts and technical aspects of the EF that make ups its foundation. The components such as Object Services, Entity Client, and LINQ to Entities will evolve but are fairly well baked. Aspects I expect to change (although I have no evidence to support it) are the way the entities are implemented. For example, I expect they may evolve into more of a POCO style with no interface nor base class required. This topic has been beaten pretty hard, so I won't add anything further to it for now since I agree with most of what has already been blogged about. There is one piece which I know is on its way, however late to the game it may be ... the EDM Designer.
Anyway ... this article is an overview of how the EF is structured and how its pieces work. I inlcuded some examples as well. It was difficult to keep the word count down on this one ... my first draft had over 7000 words in it (supposed to be about 3000). So we cut it down to a reasonable and digestable size. I hope you enjoy it!
Entity Framework: CSDL, MSL and SSDL Schemas
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 0 comments
Due to the lack of a designer and because I am very curious, I’ve been digging through the XML for the CSDL, MSL and a little bit into the SSDL schemas for the Entity Framework’s Entity Data Model. Even if you are waiting for the Designer to be released (date TBD) it cannot hurt to get familiar with these XML file structures. For example, the MSDL’s schema supports the following for the mapping Conditions:
<!-- Type for Condition Element-->
<xs:complexType name="TCondition">
<xs:attribute ref="tns:Value" use="optional" />
<xs:attribute ref="tns:Name" use="optional" />
<xs:attribute ref="tns:ColumnName" use="optional" />
<xs:attribute ref="tns:IsNull" use="optional" />
</xs:complexType>
Currently the conditions in mapping only allow you to compare a column to a scalar value or to check for NULL. You can create multiple conditions, which will create an AND situation. However you cannot combine the conditions with OR’s (i.e. you can’t say get all orders > $10,000 or orders < $100). In fact, nor can you compare values at this point (i.e. < ). These features are surely going to be in future versions, though.
By having the XSD’s for the CSDL, MSL AND SSDL you can explore what options are available even if the intellisense is not working in the latest CTP J (which has happened to me at times). For example, I noticed that complex properties are in the schema, however they are not fully supported at this time. But at least this gives me a glimpse at what might be supported in the future.
I open the XSD’s in Visual Studio.NET Orcas, but of course you can use other tools like XML Spy. Here is a snapshot of the TableMappingFragment’s schema from the MSL file:
If you are looking for the XSD’s, you can find them in the March Orcas CTP located at this folder:
C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
And the file names are:
- CSDLSchema.xsd
- CSMSL.xsd
- SSDLSchema.xsd
Entity Framework Thoughts
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 13 comments
I agree that there is quite a bit of work to do yet with the Entity Framework. Earlier today Scott posted his thoughts on the challenges that the Entity Framework faces. He makes some good points which really show how the approach to application development greatly influences which tools and development strategies developers will choose. I agree that applications have a better chance to succeed when they are "business rule" driven.
I prefer to build a data model and a business model together, not one before the other. In its current state the Entity Framework can be generated from an existing data model (or can be created by hand with XML). The data team at Microsoft knows this is a limitation and is working on solutions to make building and tweaking entities, mapping the conceptual model to a logical model, and overall design of the EDM much more fluid. I am very excited about seeing what they produce on this end.
Building off of the example that Scott worked, assume you have an entity that you are working with and realize that you need to add a new property (or field) to it to establish a business rule (or to write a test if you are using TDD). You want to add the field or property to the entity and keep moving along with your business rule (probably using Resharper or the like to create the field/property combination). The idea is to keep your brain patterns flowing with the business rule and not to step outside of tat to implement a new field/property and populate it. You want to create the additional property, use it in your code, and map it to the models quickly.
With the Entity Framework in its current state you could add a new partial class and add the field and property to it, but then you are deviating from the EDM with a field that you will eventually want to persist in the database anyway. Another option with the Entity Framework is to add the property to the conceptual model and mapping it to a database field (that you must create). This is an option that makes sense but is the most difficult to implement at this time. I believe this is one area where the Entity Framework has room to grow and the data team can add more value to the development community: Having a way to easily amend business entities, have it flow through the conceptual model ,and map them to a logical model to the database.
There is a lot left to work out and the more people who use the Entity Framework, participate in the forums, test the CTP’s, and provide feedback where they can, the better the end result will be. I believe that the data teams at Microsoft are absolutely committed to this technology and I am personally very excited about the Entity Framework ….. more excited than I have been about a technology in a long, long time.
Stored Procedures and CUD (minus the R) in the Entity Framework
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 0 comments
The Data Access Team published a great post that has some superb explanations on how to make the Entity Framework use stored procedures for inserts, udpates and deletes. (It does not yet support stored procedures for retrieving data.) Obviously there are pieces missing, as Shyam states (such as retrieving data via sprocs), but to see CUD (minus the R) working in the EF with sprocs is great.
One knock I can already hear though is how people will have to change the existing sprocs. Specifically in the example where the additional parameter must be added to support the EF's determination of which entities/sprocs to execute in which order. Obviously it would be better if a future evolution could do without this.
Fantastic to see sproc support born in the Entity Framework!
On a related note, I am having a heck of a time trying to get an overview of ADO.NET Orcas to fit into a publishable article. There is just sooooo much to it and so little space to write about it. I could go on for days on this topic :)
LINQ to Entity Samples added to 101 Samples!
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 1 comments
Earlier in March I posted that some samples intended for use with the March CTP of Orcas were available for download. These samples replace the samples that are linked from the MSDN docs in the CTP. One thing these samples lacked was the LINQ to Entities samples. Today, Charlie Calvert posted a link to updated samples that include LINQ TO Entities samples inside the SamplesQueries example project. Inside the SamplesQueries project you will find a 101 LINQ to Entities samples.
This is great news! Previously there were tons of examples in this project for LINQ to SQL, LINQ to XML, LINQ to Objects and LINQ to DataSets. With the additin of LINQ to Entities, it means I have plenty of material to play with and keep my head buried in ADO.NET and the Entity Framework.
Entity Framework and Object Services Primer
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 0 comments
As I am sure you have read by now, the Entity Framework is a huge leap forward in the next iteration of ADO.NET in Orcas. Currently the implementation has a conceptual layer represented by a CSDL file. This CSDL file contains the XML that represents conceptual model (the objects). The conceptual layer is mapped to the database through a series of lower layers (the Mapping and the Source). The Source is represented by a SSDL file which contains XML that represents the database schema. The MSL file contains the XML that maps the CSDL to the SSDL. All 3 of these files can be generated using the EDM Model Wizard in the Orcas Feb/March CTP.
Once the model has been generated (or created by hand), the data can be manipulated and interrogated through the conceptual model. Thus a level of abstraction is created where an application can interact with data through an object model that is mapped to the underlying data source. LINQ to Entities or Entity SQL can be used to interact with the EDM. LINQ to Entities is great when you can define your query expressions at design time and enhance them with parameters. Entity SQL can also be sued to achieve the same goals, however since Entity SQL is string based it can support more dynamic queries where queries can be built on the fly.
There is quite a bit to chew with the Entity Framework, more than enough for a entire series of articles. And I have not even touched on the other ADO.NET components such as LINQ to SQL or LINQ to DataSets, much less the designers, LINQ to objects, LINQ to XML, EntityClient and much much more.
It is an exciting time to be involved with data access technologies! And some unforeseen changes are yet to come as many have already experienced the changes through the CTP’s of LINQ and Orcas. But it seems evident that the data access team is making its biggest change to data access in a very long time.
Updated Samples for Orcas March 2007 CTP
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 0 comments
Charlie Calvert has posted some samples intended for use with the March CTP of Orcas. These samples replace the samples that are linked from the MSDN docs in the CTP (which is good since I have had mixed result wth them so far). Charlie also posted a video on the samples here that helps explain them.
Entity Framework Terminology
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 0 comments
I have some articles to write on the Entity Framework and LINQ to ADO.NET, so I will be busy in the depths of EF for a while. I have been spending the past few days immersing myself in the Orcas March CTP. While there are features I am still longing for (such as the EDM Designer) this is the most EF & LINQ complete CTP in a long time. While the MSDN Documentation is not complete by any means, there is some great information in there. For example, I found this fantastic page in the help docs that is a glossary of the Entity Framework terminology. I pulled this directly from their documentation, which you can find at this link (ms-help://MS.MSDNQTR.v90.en/MS.MSDN.v90/MS.VisualStudio.v90.en/WD_ADONET/html/fa2a1bd1-6118-487b-8673-eebc66b92945.htm ) in the March CTP's help docs. This is a great reference to lean on when learning the EF ... kudos to the data team for creating and including this information in the CTP.
Entity Framework terminology:
alias
An attribute of the Schema element in CSDL and SSDL schemas that can be substituted for the full namespace to shorten element references in the schema.
association
The definition of a relationship between entity types.
association set
A logical container for instances of associations of the same type.
base type
A parent type or super-type in the EDM from which derived types inherit some of their properties.
complex type
An entity type whose properties have internal properties. Used as a property of an entity type or of another complex type.
conceptual schema definition language (CSDL)
XML-based dialect used to define the entity types, associations, entity containers, entity sets, and association sets of a conceptual model.
conceptual model
Abstract specification for the entity types, associations, entity containers, entity sets, and association sets comprising an application domain.
constraint
Restricts the possible values of a property and ensures that a value is valid.
container
A logical grouping of entity and association sets.
degree
The number of entity types in a relationship. Relationships are classified as unary, binary, ternary, or n-ary.
direction
Refers to the asymmetrical nature of some associations. Direction is specified with FromRole and ToRole attributes of ReferentialConstraint elements in entity data models.
end
A participating entity in an association.
entity
An instance of an entity type.
EntityClient
A storage-independent ADO.NET data provider containing classes such as EntityConnection, EntityCommand, and EntityDataReader. Works with Entity SQL and connects to storage specific ADO.NET Data Providers, such as SqlClient.
entity container
Specifies the sets of entity types and associations that will be available in a specified namespace.
Entity Data Model (EDM)
A system for defining application data as sets of entities and relationships.
Entity Framework
A set of technologies that supports development of data-oriented software applications by allowing developers to work with conceptual models that are mapped to logical schemas in data sources.
entity-relationship model
A data model that uses relationships between entities as the basis for describing application data schemas.
entity set
A logical container for entities of the same type, mapped to tables in a database.
Entity SQL
A storage-independent dialect of SQL that works directly with conceptual entity schemas and that supports entity data model features such as inheritance and relationships.
entity type
A named set of properties representing a top-level item in a data model.
enumeration
A simple type whose single value is selected from a specified set of options.
facet
A constraint, such as Nullable, MaxLength, or Precision, that limits the allowable values for a property.
helper method
User-defined operations implemented in partial classes that add functionality to objects generated from entity data models.
key
The attribute of an entity type that specifies which property or set of properties is used to identify unique instances of the entity type.
language integrated query (LINQ)
A query syntax that defines a set of query operators that allow traversal, filter, and projection operations to be expressed in a direct, declarative way in C# and Visual Basic.
LINQ to Entities
The use of language integrated query operators with objects representing a conceptual model.
mapping
A set of correspondences between items in a conceptual model and items in a storage model.
mapping specification language (MSL)
An XML-based dialect used to map items defined in a conceptual model to items in a storage model.
metadata
Data used to describe the structure of other data, including the SSDL XML file, which describes the structure of data in a data store.
Metadata Workspace
A class that represents the metadata runtime service component that provides support for retrieving metadata.
multiplicity
The number of entities that can exist on each side of a relationship.
navigation property
A property of entity types that uses an association to reference related entities.
object services
Services provided by the Entity Framework to classes generated from a set of metadata.
object context
A base class that provides object services such as tracking and saving changes, and that contains a connection to the underlying data store.
referential constraint
An element of an SSDL entity data model that specifies the direction of an association with FromRole and ToRole attributes. Corresponds to a CSDL navigation property.
relational model
The logical model used to define the tables, columns, and constraints in a database.
relationship
A logical connection between entities.
role
The name given to each end of an association to clarify the semantics of the relationship.
simple type
Primitive type used for defining properties in entity data models.
store schema definition language (SSDL)
XML-based dialect used to define the entity types, associations, entity containers, entity sets, and association sets of a storage model, often corresponding to a database schema.
table-per hierarchy (TPH)
A method of modeling a type hierarchy in a database that includes the attributes of all the types in the hierarchy in one table.
table-per-type (TPT)
A method of modeling a type hierarchy in a database that uses multiple tables with one-to-one relationships to model the various types.
XML (simple type)
Can contain well-formed XML or valid XML data. The facets of this type control which kind of XML data can be contained within it.
Entity SQL & the EntityClient Provider in ADO.NET vNext and Orcas
Friday, February 01 2008 - net, sql, ado-net, entity-framework, linq - 0 comments
If you watch the ADO.NET team’s blog then you may have seen the post from today from Zlatko Michailov (Program Manager, ADO.NET). Here are the highlights from his post:
In this Entity SQL (eSQL) post he discusses:
- what Entity SQL is
- a brief example of how to use it to retrieve a hierarchical set of parent-children data
- (Categories and their respective Products)
- No join syntax necessary!
- an example Connection String for the EntityClient provider
- how the EntityClient returns a common DbDataReader so we can create and fill our own classes from it
- that this uses the well known ADO.NET pattern of Connection, Command, Parameter and DataReader classes
- class names are prefixed with “Entity”
- that the next Orcas release should have this functionality
- however, he explains that it will not yet be able to use DML (aka no INSERT, UPDATE, DELETE)
There are a lot of features I am looking forward to in the next Orcas CTP (hopefully a February CTP and not a March one). I have high hopes for the future with features like Entity SQL, LINQ to SQL, LINQ TO DataSet, EDM, and LINQ to Entities. Kudos to the ADO.NET team for taking this direction!
Interesting Orcas & LINQ Links
Friday, February 01 2008 - net, ado-net, entity-framework, linq - 3 comments
Here are a few good links to Orcas material (some old and some new). There is a lot of good and bad material out there with LINQ. These are some of the better ones that I have found. Feel free to comment about any other good LINQ / Data Access related links.
Downloads:
· The best way to run LINQ with the most features using the current CTP’s remains to be to
o create a VPC image
o install the May 2006 LINQ CTP,
o the August 2006 ADO.NET vNext CTP,
o and the September 2006 ADO.NET vNext EDM Designer Prototype CTP.
Books:
· Here is a great book on using LINQ and the C# 3.0 features by Fabio Claudio Ferracchiati titled LINQ for Visual C# 2005. The material is slightly dated as it was written with early previews, but its still a great read.
· Here is Ferracchiati’s VB version of that same book.
· This book (titled Foundations of LINQ in C# 3.0) is not out yet, but is scheduled for a March 1 release date. IT looks to be interesting based on some of Joseph Rattz’s blog posts.
C# 3.0 Features
· Anders Hejlsberg has a great video on how C# 3.0 is evolving. This discussed many of the C# 3.0 features that are the underpinnings of what makes LINQ tick. (posted mid 2006)
· Sahil Malik has some great posts on C# 3.0. I recommend getting familiar with the C# 3.0 features before jumping into any of the Orcas /ADO.NET vNext data access features.
o Demystifying C# 3.0 - Part 1: Implicitly Typed Local Variables "var"
o Demystifying C# 3.0 - Part 2: Anonymous Types
o Demystifying C# 3.0 - Part 3: Extension Methods
o Demystifying C# 3.0 - Part 4: Lambda Expressions
o Demystifying C# 3.0 - Part 5: Object and Collection Initializers
o Demystifying C# 3.0 - Part 6: (LINQ) Query Expression Translation (to C# 3.0)
o Demystifying C# 3.0 - Part 7: Expression Trees
Next Generation Data Access & LINQ Basics
· A good place to start with LINQ is the Next Generation Data Access article. This explains some of the ideas behind ADO.NET vNext. (posted mid 2006)
· In the MSDN Forums, Dinesh hints that the March 2007 Orcas CTP is planned to LINQ features on par with the May 2006 LINQ bits. There have been rumors of the next CTP being February 2007 or March 2007.
· Some good information and questions/answers exist on the LINQ Project MSDN forum as well as the ADO.NET Orcas MSDN forum.
· Here is a nice post that compares and contrasts LINQ to Entites and LINQ to SQL.
· Scott Guthrie has been posting some great slide decks on LINQ, ADO.NET vNext, and Orcas in general at his blog.
o Links to some good presentations
· The ADO.NET Team blog shows some good information on:
o Entity Data Model 101: Part 1
· Sahil Malik has some great posts on Demystifying DLINQ:
o Demystifying DLINQ: Part1 - An introduction to DLINQ
o Demystifying DLINQ: Part2 - Setting up a DataContext Class
o Demystifying DLINQ: Part3 - Querying for Data using DLINQ
o Demystifying DLINQ: Part 4 - Stored Procedure/UDF Support in DLINQ
o Demystifying DLINQ: Part 4.1 - Stored Procedures that return scalar results
o Demystifying DLINQ: Part 4.2 - Stored Procedures that return a definite shape
o Demystifying DLINQ: Part 4.3 - Stored Procedures that return variable shapes
LINQ 101 - Which Flavor?
Friday, February 01 2008 - net, entity-framework, linq - 0 comments
LINQ has permeated the .NET world. How to use LINQ, the different types of LINQ, how LINQ’s query expressions break down into C# 3’s newest features, and so on. LINQ has even had some of its old names tossed aside in the process. For example, LINQ to SQL was formerly known as DLinq. For the most part I have quietly indulged in all things LINQ and avoided writing too much on the specific syntaxes of how/when to use it (or not to use it). But now that LINQ, ADO.NET vNext and Orcas are getting close to the point where significant changes are less likely, I thought I might answer some fundamental questions about the flavors of LINQ in a brief post.
Once people get into LINQ, the biggest confusion I get email on regarding LINQ is how to choose between LINQ to SQL (formerly DLinq) and LINQ to Entities. In short, LINQ to SQL allows you to query an object model that maps directly to your relational database schema. The mapping is 1 class object to 1 db schema object. This is a simpler form than the abstraction model of LINQ to Entities …. which allows you to query an object that can be translated into 1 or more tables (for example) in your database. With LINQ to entities, the object model that you query with LINQ can be very different than the database schema.
Here is a quick primer on some of the flavors of LINQ:
LINQ to SQL (Formerly known as DLinq) | Objects get mapped directly to database tables. Basically lets you perform LINQ queries directly on the database schema via objects. If your existing architecture has objects that map 1 to 1 with your database schema, then LINQ to SQL would be the closest match. Add a *.dlinq file and drag tables/procs/table value functions/views from Server Explorer to the designer. Can also use SQLMetal to generate classes. |
LINQ to Entities | Provides a layer of abstraction from the relational database structure. (aka you can combine tables into a single class, or you can use inheritance). Objects can represent the relational tables in OOP There is a conceptual model, a database schema, and then there is the mapping between the 2. The conceptual objects are mapped through an XML mapping on to the database schema. Add a .edm model file and create entities and their associations in the designer. Can also generate an EDM model (with the .ssdl, .csdl, .msl and .cs files). |
LINQ to XML (Also known as XLinq) | LINQ over XML structures |




