- We design and build extraordinary applications for companies looking to make the next great idea a reality.
- learn more
LINQ to My Domain
I've begun my foray into the world of LINQ, and in my investigation I've seen a lot of work based on the LINQ to SQL "design surface" available in Visual Studio 2008. It's a neat tool. I point it to my database, drag some tables over, and it infers my domain structure and relationships from the databases fields and keys. That's all well and good for a simple domain model that is directly related to the database schema. I could see using this for a quick prototype, or a really small application. I see three files created by the designer:
MyClasses.dbml - This looks like any ORM frameworks mapping file. It associates classes with tables, maps fields to object properties, and defines relationships.
<Table Name="dbo.Balloons" Member="Balloons"> <Type Name="Balloon"> <Column Name="BalloonId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="Color" Type="System.String" DbType="NChar(20)" CanBeNull="true" /> <Association Name="Balloon_Kid" Member="Kid" OtherKey="KidId" Type="Kid" /> </Type> </Table>
MyClasses.dbml.layout - This looks to be specific to the layout of the design surface and appears to serve no purpose outside of this design.
MyClasses.designer.cs - This is the beast that I'm looking to replace. It contains the class definitions and attribute based mappings to bring my database schema into my application, and ready it for use by LINQ.
So this leaves me with a couple questions. One, why are attributes used to specify mappings? Can this be done strictly via XML? More importantly two, can I use my own domain model, and if so how do I map it to the database?
My goal would be to design a layered system, separating the underlying data store from the repositories required to push and pull my domain objects from these data stores. This would allow in memory implementations of the data store, and would make unit testing (and developing) a whole lot easier. I will be digging into this in the coming days and will report back soon. Stay tuned!
Leave a comment
About Pathfinder
Recent
- Firefox Plugin Malware ‘Trojan.PWS.ChromeInject.A’
- Pathfinder releases version 1 of the its Flash Platform microsite (codename Mica)
- Pimp my Rails: Five Plugins & Gems to Make Rails Better
- iPhone: Using Pre-processor Directives for Device Testing
- Subtle OpenGL Projection Matrix Difference Between iPhone Simulator and Device
- App Security: Throw Out the Org Chart!
- Pimp my jQuery: Five plugins to replace the features Prototype and Scriptaculous users expect
- Thanksgiving 2008: What We’re Thankful For (In Rails)
- iPhone SDK: Testing with TextMate & GTM
- GWTQuery - JQuery-like Syntax in GWT
Archives
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006

