Posts
  • Meta-Me

    Tip 20 – How to deal with Fixed Length Keys

    • 6 Comments
    This is 20th post in my ongoing series of Entity Framework Tips . Fixed Length Field Padding: If you have an fixed length column in the database, for example something like NCHAR(10) when you do an insert, padding happens automatically. So for example...
  • Meta-Me

    Tip 6 - How and when to use eager loading

    • 5 Comments
    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...
  • Meta-Me

    Tip 5 - How to restrict the types returned from an EF Query.

    • 9 Comments
    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...
  • Meta-Me

    CQRS with OData and Actions?

    • 5 Comments
    I love the Actions feature in OData – which is hardly surprising given I was one of its designers.  Here’s the main reason why I love it: Actions allow you move from a CRUD architecture style, where you query and modify data using the same model...
  • Meta-Me

    Tip 36 – How to Construct by Query

    • 6 Comments
    While writing my tips series and writing EF controllers for MVC I found that I regularly wanted to create and attach a stub entity . Unfortunately it isn’t quite that simple, you have to make sure the entity isn’t already attached first, otherwise...
  • Meta-Me

    Hydrating a DataTable from an EntityDataReader - part 1

    • 3 Comments
    Okay so about 5 posts back I promised: "...At this point we have an enumeration of all EntitySet s available. In the next post I explain how we can use that…" Well better late than never... If you remember last time I showed you this piece of...
  • Meta-Me

    Maybe I'm just a little slow...

    • 9 Comments
    But I only just realized that extension methods are cool for avoiding NullReferenceExceptions . We all know that if you have something like this: LicensePlate licensePlate = null ; Car car = licensePlate.Car; It will throw a NullReferenceException...
  • Meta-Me

    ObjectQuery<T>.ToTraceString() and possibilities...

    • 4 Comments
    So in Beta3 of the EntityFramework (due out very soon) the team added a new function to ObjectQuery <T> that allows you to get the native Query that would be evaluated if you enumerated. I.e. if you are using the System.Data.SqlClient that would...
  • Meta-Me

    Associations with Payloads

    • 10 Comments
    Those of you who know what I am talking about will probably also know that we have been saying publicly that the Entity Framework doesn't support them. Now for those who don't know what an association with a payload is, imagine something like: Order...
  • Meta-Me

    Hydrating a DataTable from an EntityDataReader - Part 2

    • 1 Comments
    See yesterday's post for some context... So we can't rely on EntityDataReader . GetSchemaTable() and a DataAdapter to do the filling of our DataTable for us. We have to do it ourselves. As with any problem the first step is to define the steps:...
  • Meta-Me

    Code-Only best practices

    • 3 Comments
    There have been lots of posts on the EFDesign blog talking about how the features in Code Only have evolved. But very little covering what we think will be the best way to write the code. You may have seen code like this: var prodConf = builder.Entity<Product>...
  • Meta-Me

    A silly C# trick from the trenches

    • 7 Comments
    UPDATE: as Joe rightly points out in the comments (thanks Joe) when you try to pass a Func<T,V> to a method expecting Action<T> using lambda syntax it doesn't fail. Somehow the compiler must realize there is no match for Func<T,V> and...
  • Meta-Me

    LINQ to Objects and Buffer<T>

    • 3 Comments
    I was debugging a problem a couple of days ago, when I learned something interesting. I had some code that looked like this: foreach(Employee e in manager.Manages) { … } The manager.Manages property returned a custom implementation of ICollection<Employee>...
  • Meta-Me

    Tip 31 – How to compose L2O and L2E queries

    • 2 Comments
    Imagine you want to write a query like this: var possibleBuyers= from p in ctx.People where p.Address.City == “Sammamish” && InMarketForAHouse(p) select p; Now theoretically this is possible so long as there is a SQL translation for InMarketForAHouse...
  • Meta-Me

    DefiningQuery versus QueryView

    • 2 Comments
    Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 ...
  • Meta-Me

    Tip 4 - Conceptual Schema Definition Language Rules

    • 2 Comments
    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...
  • Meta-Me

    Tip 39 – How to set overlapping Relationships – EF 4.0 only

    • 1 Comments
    Scenario: In EF 4 we have FK relationships , available for the first time in .NET 4.0 Beta 2, so it is now possible to have a model something like this: public class Division { public int DivisionID {get;set} // Primary Key public string Name {get;set;...
  • Meta-Me

    All the power at your disposal

    • 3 Comments
    I invite you to take a look at this forum post from 'Benys' It illustrates the power of the Entity Framework's mapping capabilities + partial classes. The short answer to a lot of "Does the EF support ... ?" type questions is often no. Often however the...
  • Meta-Me

    Software Development Meme

    • 1 Comments
    So thanks Danny for giving me a ping... it's been a while since I participated in one of these blog chain letters. Funny really because now I am a Program Manager, I'm not a real developer anymore ;) How old were you when you first started programming...
  • Meta-Me

    Tip 29 – How to avoid LazyLoad or Load() reader issues

    • 1 Comments
    If you have code that looks like this: var results = from c in ctx.Customers where c.SalesPerson.EmailAddress == “…” select c; foreach(var customer in results) { Console.WriteLine(customer.Name); if (IsInteresting(customer)) { customer.Orders.Load...
  • Meta-Me

    Side effects of first class Associations

    • 9 Comments
    You've probably all heard someone say that Entity Data Model (EDM) and more specifically the Entity Framework (EF) treat associations as first class concepts. This sentence, seems reasonably benign, but it has a profound effect on the Entity Framework...
  • Meta-Me

    Is hiding lower level APIs bad?

    • 6 Comments
    There are many good arguments for hiding away the lower layers in your stack – essentially the building blocks upon which your public API is built - however the ‘ we don’t have the time and resources to test that layer completely ’ argument seems a little...
  • Meta-Me

    Tip 47 – How fix-up can make it hard to change relationships

    • 2 Comments
    Problem: Take this code: Category oldCategory = ctx.Categories .Include("Products") .First(c => c.Name == "Drink"); Category newCategory = new Category {Name = "Beverage"}; foreach(Product product in oldCategory.Products) { newCategory.Products...
  • Meta-Me

    Tip 40 – How to materialize presentation models via L2E

    • 5 Comments
    Problem: Imagine that you have these entities public class Product { public int ID { get; set; } public string Name { get; set; } public virtual Category Category { get; set; } } public class Category { public int ID { get; set; } public string Name ...
  • Meta-Me

    Video on Entity Framework’s Model First in .NET 4.0

    • 1 Comments
    How did I miss this ? Jonathan Carter (aka LostInTangent ) has done a Channel 9 video on our upcoming Model First experience. Model first was announced a while back here .
Page 4 of 7 (151 items) «23456»