Thomas's profileBlogsBlogLists Tools Help

Blog


    02 March

    Urban legends - Truth or Myth?

     

    Select with EF is always slower than with Linq2SQL

    This is only true when you leave the default value of ObjectQuery.MergeOption or set it to any other value but MergeOption.NoTracking. However, if you do set this value to MergeOption.NoTracking, a select will be 3 times faster than with LINQ2SQL.

    The following table compares various scenarios:

    Method

    Duration (ms)

    DataReader

    580

    DataTable/DataAdapter

    2050

    Linq2SQL with Tracking

    3330

    Linq2SQL without Tracking

    2550

    EDM with MergeOption != NoTracking

    4600

    EDM with MergeOption = NoTracking

    1150

    So what you see here is that EDM is the fastest access after DataReader, but also the slowest if tracking is (by default) enabled. Depending on what you do, you might consider to disable Tracking for faster read access, but with the possibility of redundant data in memory.

     

    Linq2Sql supports MS SQL only

    This is not really true! Though there is currently only one IQueryProvider for MS SQL, but who prevents other SQL Provider to implement their own IQueryProvider? For instance, Oracle offers native DbConnection, DbCommand and DbReader, why not a QueryProvider?

     
     
    EDM does not support UDF (User defined Functions)

    Unfortunately, as with .NET 3.5 SP1 this is true. Though you can currently describe a function with

    <Function Name="MyUDF" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" ReturnType="nvarchar(max)">

    <Parameter Name="title" Type="nvarchar(max)" Mode="In" />

    </Function>

    where it differs from a stored procedure by IsComposable set to true instead of false, there is currently no support for it. Usage of UDF with EF is announced to be available with .NET 4.0

     
     
    Linq2SQL can do everything that EF can do and more

    No. There are some features that is currently not possible with EF, but there are also features in EF that is not available with Linq2SQL.

    • EF is significantly (>300%) faster in writing and updating data back to the database
    • EF supports n:m relations which Linq2SQL doesn't
    • Linq2SQL supports contains in query, while EF (currently) doesn't
    • Linq2SQL supports UDF, EF doesn't (with Framework 3.5SP1)

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://thomasgerber.spaces.live.com/blog/cns!58B30559C82E269C!679.trak
    Weblogs that reference this entry
    • None