Click here to Skip to main content
15,885,839 members
Articles / Programming Languages / XML
Tip/Trick

Sharp RepoGen

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
7 May 2014CPOL2 min read 9.4K   94   5   1
Sharp RepoGen is a simple tool to create repository interface having methods for CRUD operation and its implementing class. Using this tool easily you can generate your repositry class and interface. Code is generated with the help of xml template, so very easily you may change the template to creat

Sample Image - maximum width is 600 pixels

Introduction

If you are planning to use Repository pattern in your project, then 'SharpRepoGen' is definitely going to be a best help for you. Using this you may avoid creating the similar pattern Repositry Classes and its interfaces. Using this tool easily you can generate your repositry class and interface. Code is generated with the help of xml template, so very easily you may change the template to create your source code as per your requirement. Section Tools, Design Pattern

Background

Repository Design pattern now a days has become very popular. This tool helps to implement the same without much effort.

Using the Code

Tool does most of the things for you, you simply need to provide your database credentials for which you want to create CRUD.

You simply need modify Template xml (basic setting done) to achieve your own naming conventions and coding standards.

Download the demo project and unzip the downloaded file.

  • You will see SharpRepoGen.exe file, double click it to Run.
  • Enter your database credentials and hit login.
    Image 2
  • You will be redirected to a new screen where, you will see your database tables on the left.
  • Select your tables for which you want to generate the repository classes. Use Ctrl + A and Ctrl + N to Select All/ Select None.
    Image 3
  • Hit F5 to generate the repository classes.
  • Select appropriate radio button Interface/ Repository Classes to see the files generated. You may click on file name to preview the same.
    Image 4
  • Hit Ctrl + T to modify the template if you want to modify the template.
    Image 5

    As discussed earlier, that source code is generated with the help of xmls, so that we can modify it easily. (Template.xml). So this option enables you to do the changes as per your need e.g. Changing namespace or any naming convention.

    Tool generates two objects, one is interface and another is its implementing class. Suppose, your table name is User, then it generate objects i.e. classes and interface with name IUserRepositry and UserRepository. Also, it generate CRUD functions as GetUsers, GetUserById, InsertUser, DeleteUser and UpdateUser. If you want any changes in these emails, you may change corresponding template (interface/ repository), highlighted below with yellow color.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Legalxgen.Entity.DataAccess;

namespace Legalxgen.DataAccess.Repository
!cur_brak_op#
    public interface I{0}Repository
    !cur_brak_op#
      IEnumerable<{0}> Get{0}s();
      {0} Get{0}ByID(int {1}Id);
      void Insert{0}({0} {1});
      void Delete{0}(int {1}Id);
      void Update{0}({0} {1});
      void Save();
    !cur_brak_cl#
!cur_brak_cl#

Points of Interest

On the development point of view its pretty straight forward, but on the usage side its quite waste, it reduces your effort to create these interfaces and classes.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Aspirea Technologies Pvt Ltd
India India
• 8 years of experience in IT Industry as a Developer.
• Experience of End-To-End Software Development and Implementation (Entire SDLC i.e Software Development Life Cycle)
• Real time Exposure to Banking, Finance and Energy industry.
• Expertise in distributed application architecture as well as web based applications using Microsoft.NET platform.
• Expertise in database design, SQL programming and SQL performance tuning.
• Expertise in Web Services and WCF Services.
• Experience of Rich Internet Application using Adobe Flex.
• Experience in migration of legacy application to latest technology, migration of VB application to .NET.
• Knowledge of OOPS and Design Concepts.
• Expertise in Agile/ Scrum software development processes.

Specialties
• Languages\ Technologies-
.NET Framework 1.1/2.0/3.0/3.5, C#.NET, VB.NET, ASP.NET, VB6, AJAX, ASP.NET, Adobe Flex 3.0, Web Services, Windows Communication Foundation (WCF), LINQ, SQL Server, Oracle, MySql, MS Access, HTML, XML, JavaScript, C# Script, CSS and XSLT.

• Methodology/ Concepts-
OOPS, Data Structures, Design Concepts and Agile/ Scrum Software Development

Comments and Discussions

 
-- No messages could be retrieved (timeout) --