Monday, November 29, 2010

EF4 ToTraceString Method

So if your SoC is just a little muddy on the db-code to query-code like mine appears to be currently you might find yourself wanting to access the ToTraceString() method cleanly on the query side without bringing in EF4 using statements or references.

I accomplished this using the partial class feature.





using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Data.EntityClient;
 
namespace StarfleetCommanderSecure.EF4
{
    public partial class SfeEntities
    {


 public string ToTraceString(IQueryable query)
        {
            var objectQuery = (System.Data.Objects.ObjectQuery) query;
            return objectQuery.ToTraceString();
        }


    }
}

No comments:

Post a Comment