How can I Separate DATACONTEXT and Entities to Different dll? RRS feed

  • Question



    As per our application design, we are keeping our Business entities in DTO.dll and the DataService(DataContext) in DAL layer.


    But in LINQ both are kept in same DLL.


    How can I Move that into diff project?

    Monday, March 17, 2008 10:18 AM



    Actually there's no current limitation to separate your DataContext class from your Entities classes, but the default code generator (MSLinqToSQLGenerator) generates all in one file.


    You can copy the DataContext file moving all the entities to a separate file, and obtain your tables using the GetTable<T> method:


    using (DataContext dc ....) {

    var query = dc.GetTable<Products>().Where(.....



    by having your DataContext and Entities in separate files, you can split them in your Dal and DTO assemblies


    In my company we have published (with GPL) a custom tool that allows you to replace the default code generator to allow (among other things) separate DataContext from Entities





    Monday, March 17, 2008 12:34 PM