views:

55

answers:

2

I use the repository pattern for pretty much all of my projects. I have a .edmx/.dbml file that has my database tables referenced, and then for each table I create a 'Tablename'Repository.cs

Each of these classes have the same methods with only the type of table being called being changed.

public IQueryable<Area> FindAll()
public IQueryable<Department> FindAll()
public IQueryable<Boss> FindAll()

Any suggestions? This would really cut my cruft development time and I think people would enjoy using it.

Thanks!

+3  A: 

you be needing t4 templates then ...

http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx

Read Scotts as the start - he handly reference other resources to get you started and reference things for the Entity Framework/Linq2SQL

MSDN StartPage for t4

jpg
You might want to check in to the [POCO Template extension](http://thedatafarm.com/blog/data-access/using-the-beta-2-ef-poco-template-with-vs2010-rc/) for VS2010, as they use T4s to generate code based on an EDMX. It ought to be reasonably easy to modify their templates to create repositories instead of POCOs.
ladenedge
A: 

Hola Sergio!

I would be the first interested in using your code!

Creating a template for Visual Studio, as jpg mentioned, is an option but you could also create an assembly library containing all the useful methods you are describing.

This is way, people could add the assembly to an already existing project more easily. If your library gets really useful, you could even open-source it on codeplex or github.

jdecuyper