IC窗口
community.icburner.com
All Tags » Tip (RSS)

Browse Blog Posts by Tags

Showing related tags and posts for the Blogs application. See all tags in the site
  • Tip 1 - How to sort Relationships in Entity Framework

    Question: One of the questions you often see in the Entity Framework Forums is around sorting related items. For example imagine if you want to query customers, and return only those that have accounts more than 30 days in arrears, and at the same time retrieve their orders. And you need those orders...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 2 - Entity Framework Books

    Question: Where do I find in depth books on the Entity Framework? Answer: One of the benefits of being on a product team a Microsoft is you get authors who want you to review their books. So far to date I've have had 3 different authors send me copies of their Entity Framework books. Here they are...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 3 - How to get started with T4

    So if you've been reading the Entity Framework Design Blog you will have heard us talk about T4 . It is a technology that ships with Visual Studio 2008 (and 2005 as a separate download). In .NET 4.0 the Entity Framework is leverage T4 to help with Code Generation and Model First scenarios. In fact...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 4 - Conceptual Schema Definition Language Rules

    The first version of the Entity Framework was released a while back ago now with .NET 3.5 SP1. One of the most glaring holes in the Entity Framework documentation was the lack of a formal document describing the Conceptual Schema Definition Language or CSDL. The CSDL for those who are wondering is the...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 5 - How to restrict the types returned from an EF Query.

    Imagine you have a model that looks like this: How do you query for just Cars? This is where OfType<SubType>() comes in. You write something like this: var onlyCars = from car in ctx.Vehicles.OfType<Car>() select car; And this works, fine. It restricts the results to just Cars, which incidentally...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 6 - How and when to use eager loading

    When should you use eager loading? Usually in your application you know what you are going to "do" with an entity once you have retrieved it. For example if you retrieve an order so you can re-print it for a customer, you know that the re-print would be incomplete without information about...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 7 - How to fake Foreign Key Properties in .NET 3.5 SP1

    Background If you've been reading the EF Design Blog you will have seen that we recently announced something called " FK Associations " for the EF in .NET 4.0. However in .NET 3.5 SP1, we only support Independent Associations. What that means is that the FK Columns aren't available...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 8 - How to write 'WHERE IN' style queries using LINQ to Entities

    Imagine if you have a table of People and you want to retrieve only those whose the Firstname is in a list of interesting firstnames. This is trivial in SQL, you write something like this: SELECT * FROM People WHERE Firstname IN ('Alex', 'Colin', 'Danny', 'Diego') A SQL...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 9 – How to delete an object without retrieving it

    Problem The most common way to delete an Entity in the Entity Framework is to pull the Entity you want to delete into the context and then delete it like this: // Find a category by ID by // TRIVIA: in .NET 4.0 you can use .Single() // which will throw if there is more than one match. var category =...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 10 - How to understand Entity Framework jargon

    The Entity Framework is pretty big, so when the Entity Framework team talks about things internally we tend to use jargon to increase communication 'bandwidth'. Unfortunately sometimes we let this Jargon slip into our APIs and communication. Now jargon is fine if you are in on the secret, but...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 11 – How to avoid Relationship Span

    Background and Motivation: In my last post on EF Jargon I introduced the concept of Relationship Span. If you remember Relationship Span is basically responsible for compensating for the lack of Foreign Key properties* in your Entity. Relationship Span for an Entity, lets say StaffMember, insures that...
    Posted to VS2010学习 by 革命 on 2009/6/22
    Filed under: Filed under: ,
  • Tip 12 - How to choose an Inheritance Strategy

    The Entity Framework supports 3 primary inheritance strategies: Table Per Hierarchy (TPH): In TPH, all data for a type hierarchy is stored in one table, and there is a discriminator column that is used to establish the type of a particular row (i.e. 'C' for Car or 'B' for Boat). Columns...
    Posted to VS2010学习 by 革命 on 2009/6/20
    Filed under: Filed under: ,
  • Tip 13 - How to Attach an Entity the easy way

    The Problem: In some of earlier tips we talked about using Attach to load things into the ObjectContext in the unchanged state without wearing the cost of doing a query. Attach is the weapon of choice if performance is your goal. Unfortunately our APIs aren't tailored for the 99% case, which is where...
    Posted to VS2010学习 by 革命 on 2009/6/20
    Filed under: Filed under: ,
  • Tip 14 - How to cache Entity Framework Reference Data

    Scenario: In order to make applications perform it makes a lot of sense to cache commonly used reference data. Good examples of reference data include things like States, Countries, Departments etc. Generally you want to have this data readily at hand, so you can populate dropdown boxes etc. A good example...
    Posted to VS2010学习 by 革命 on 2009/6/20
    Filed under: Filed under: ,
  • Tip 15 - How to avoid loading unnecessary Properties

    Problem: Imagine if you query blog posts: var myPosts = from post in ctx.Posts orderby post.Created descending select post; Just so you can output the post titles etc. foreach(var post in myPosts) { Console.WriteLine("{0} on {1}", post.Title, post.Created); } Well you've just done a lot...
    Posted to VS2010学习 by 革命 on 2009/6/20
    Filed under: Filed under: ,
Page 1 of 2 (28 items) 1 2 Next >