Create record pattern with C # UI repository

0

I created a repository with EF6 on my system, every record that I have access to the methods of my repository to commit the actions I need (Insert, Delete etc ...). The problem is that my system is very large and I need to gain agility when creating registrations, I thought then to create a control with the screen pattern that I need and in the buttons that will call my repository to perform the actions I think about creating informed properties what is the table of my Model. Does anyone have some north to create something similar?

    
asked by anonymous 15.07.2014 / 18:07

1 answer

1

I would do something using Generics :

public interface IComum<T>
    where T: class, IModeloDeDados
{
    IEnumerable<T> Selecionar();
    IEnumerable<T> Selecionar(IEnumerable<Operador> parametros, IEnumerable<string> campos = null);
    void Incluir(T objeto);
    void Atualizar(T objeto);
}

I better clarify the issue in this answer .

Just by clarifying, in this example, Operador is a special class that is transformed into a SQL statement because the project does not use the Entity Framework, but there are other answers here with the implementation supporting lambda expressions .

Make your repository classes implement this interface by passing the desired data object as a type in T :

public class Pessoas : Comum<Pessoa> { } 

Pessoa , in this case, you need to implement a IModeloDeDados interface, so the repository does not accept any object.

    
15.07.2014 / 19:01