Friday, March 26, 2010

Bugs in the generated code of Repository Factory for Visual Studio 2008

If you are considering using repository factory for visual studio 2008 in your next project, please be aware that it had 2 bugs in code generation. These are in the generated Remove method in the repository classes of the DAL. This happens only if the corresponding table is a bridge table that links two tables together.

If you had simple three tables in your database like the following:


The generated Remove method in User_RoleRepository class will be like the following:

public void Remove(System.Int32 role_IDSystem.Int32 user_ID)
   IDeleteFactory<DeleteUser_RoleIdentity> deleteFactory = new 
      DeleteUser_RoleIdentity deleteUser_RoleIdentity = new 
         DeleteUser_RoleIdentity(role_IDField, user_IDField); 
      base.Remove(deleteFactory, deleteUser_RoleIdentity); 
   catch (SqlException ex) 
      HandleSqlException(ex, deleteFactory); 

  • The parameter separator had been omitted

  • The parameters passed to deleteUser_RoleIdentity had been suffixed by “Field” although it should be the same name as the passed parameters.

Take care of these 2 bugs in the generated code, you have to correct them in every class.