Coder Social home page Coder Social logo

tugberkugurlu / genericrepository Goto Github PK

View Code? Open in Web Editor NEW
118.0 28.0 44.0 1.48 MB

(NOT MAINTAINED, SEE README) This little project contains a Generic Repository implementation for several data access platforms such as Entity Framework

License: Microsoft Public License

PowerShell 4.38% C# 95.62%

genericrepository's Introduction

โš ๏ธ THIS REPOSITORY IS NOT MAINTAINED ANYMORE. IF YOU WOULD LIKE TO VOLUNTEER TO BE THE MAINTAINER, PLEASE CONTACT ME.

This little project contains a Generic Repository implementation for several data access platforms such as Entity Framework.

You can find more information about the main idea of this pattern and the usage on ASP.NET MVC along with Unit Testing by visiting the below links:

How to Install

You can directly install this little project from Nuget. There are two packages:

GenericRepository

PM> Install-Package GenericRepository

Generic Repository Insrastructure For .NET Applications

GenericRepository.EF

PM> Install-Package GenericRepository.EF

Generic Repository DbContext Implementation

Releases

Under the master branch, you can find the latest stable release of this project.

Also, you can see the most up-to-date project under develop branch. Repository under develop branch is possibly the unstable version of the project.

You can also find all the releases under Tags section.

genericrepository's People

Contributors

bmccord avatar tugberkugurlu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

genericrepository's Issues

Upgrade to EF6 to support async database operation

ASYNCHRONOUS REPOSITORY PATTERN WITH ENTITY FRAMEWORK 6

I am trying to upgrade Generic Repository to EF 6 to support async database operation. It is really important milestone for my project to upgrade all my repositories because I am trying to get data through "Service" interface.

I have "Service" interface such as IProductService. That service implementation can be changed from web.config file so the data can be retrieved from ProductRepository or ProductService. ProductRepository is a subclass of IEntityRepository so the data is coming from entity framework.
ProductService is a class to get data through Asp.net MVC API as a json and then parse it to the Product class.

ProductRepository a method..
public List GetProductByType(int storeId, string typeName)
{
return
this.FindBy(
r => r.StoreId == storeId && r.Type.Equals(typeName, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
ProductService a method.
public List GetProductByType(int storeId, string typeName)
{
SetCache();
string url = string.Format("http://{0}/api/{1}/GetProductByType?storeId={2}&typeName={3}", WebServiceAddress, ApiControllerName, storeId, typeName);
return HttpRequestHelper.GetUrlResults(url);
}

I am trying to async all these method to get data so that I will use the advantage of async-await, asynchronous programming.

Exception adding new entities after upgrading to EF 6

I'm getting this error when adding and saving a new entity after upgrading to EF 6.

Method not found: 'Void System.Data.Entity.Infrastructure.DbEntityEntry.set_State(System.Data.EntityState)'.

Any ideas?

p.s. We are using GenericRepository.EntityFramework

The specified type member 'Id' is not supported in LINQ to Entities.

I am getting the following exception when I tried to get single entity with method named 'GetSingle(Id)' .My entity class has integer identifier but it is not 'Id', it is SiteId.

The specified type member 'Id' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

I think Linq is trying to use Id field to generate sql query to get data but my primary identifier field is 'SiteId'

Is there any way to specify entity identifier?

public partial class se_Sites : IEntity
{
public int Id { get { return SiteId; } set { SiteId = value; } }
public int SiteId { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }

} 

Paginate: Exception Thrown with 0 Index for PageIndex

I think there may be a problem with the Paginated-related code.

I incorporated your repository (EntityRepository) into a project of mine. Whilst running a few scenarios, I found that if I made a call to the overload of Paginate, which takes PageIndex and PageSize as parameters, and passed in a PageIndex of 0 (e.g. Paginate(0, 2)) then an exception would be thrown in the extension method ToPaginatedList.

That would mean you would be passing -2 into the
Skip method. The actual text of the ArgumentException is

Count must have a non-negative value. Parameter name: count

Then I thought you possibly wanted to use an index of 1 for the first page instead of 0. But that does not seem to be the case as I got erroneous results testing that theory.

Let me know if you cannot reproduce the error.

Cheers

A non Int32 based Id throws compiler error (e.g.: try with long)

edit: nevermind, I'm a dumbass :)

consider this class, interfacing your IEntity

public class Cities: IEntity<long>
{
    public long Id { get; set; }
}

Somewhere in your code it goes awry, because I get the following error:

The type 'ClassLibrary1.Cities' cannot be used as type parameter 'TEntity' in the generic type or method 'GenericRepository.EntityFramework.IEntityRepository<TEntity>'. There is no implicit reference conversion from 'ClassLibrary1.Cities' to 'GenericRepository.IEntity<int>'.

Could you please explain what needs to be done for it to work?

solution:

private readonly IEntityRepository<Cities, long> _repoCities;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.