And Nice revert back @Brent Jenkins. ;) Please let people think what else they want. It's upto them how they represent themselves to others as it describes their atticates which matters equal to technical strength.
Amy Dev
Posts
-
Why should I use Interface type of object in Constructor instead of Actual Class Object -
Why should I use Interface type of object in Constructor instead of Actual Class ObjectThanks mate.I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum. Regarding your answer, Thanks a lot for that. I got the point. I agree that was a stupid question but looking at someone else code in such a large application confused me. Thanks
-
Why should I use Interface type of object in Constructor instead of Actual Class ObjectThanks mate. Nice catch. I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum. My apologies for wasting your precious time.
-
Why should I use Interface type of object in Constructor instead of Actual Class ObjectThanks mate. I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum. Parallely I'm going through your referenced Link. :) Really thanks
-
Why should I use Interface type of object in Constructor instead of Actual Class ObjectThanks mate. Nice catch. I wish you continue your these kind of annoying replies.
-
Why should I use Interface type of object in Constructor instead of Actual Class ObjectThanks mate. Nice catch. I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum. Just in case if you are interested then my answer is, I tried to abstract as much complexity I can hide from my code but I forgot this one here. Actually this method is coded as per parallel programming.
-
Why should I use Interface type of object in Constructor instead of Actual Class ObjectThanks mate. Please find it out yourself. I posted this question here by mistake. I appreciate your response.
-
Why should I use Interface type of object in Constructor instead of Actual Class ObjectI've outsourced my enterprise level project to a freelancer and I got a quite good setup too. But now that contract has finished and the person has also moved to a new technology, in other words not willing to extend the contract. Now I'm looking into this code on myself. I do have a 2 3 years of background in C# and MVC. Below is a rough idea of my application architecture. Hopefully I've tried my best to abstract the architectural details of an enterprise level application. Please let me know if you need further brief on any of the questions. All my Entities are defined as C# POCO classes as:
public class Product : BaseEntity
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}Now I've a IDbContext like as :
public interface IDbContext : IDisposable
{
IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity;
}Base Entity is a Partial POCO class that each POCO entity is inheriting. Here is a class that implements this IDBContext as:
public class MyObjectContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
{
return base.Set<TEntity>();
}
}Now I've defined a IDbContextFactory that is responsible for providing the DBContexts as :
public interface IDbContextFactory
{
Lazy<IDbContext> CreateDbContext();
}The class implementing this IDBContextFactory interface is having below structure :
public class MyDbContextFactory : IDbContextFactory
{
public MyDbContextFactory(string dbConnectionString)
{
_dbConnectionString = Settings.DbConnectionString;
_dbContext = CreateDbContext();
}public IDbContext CreateDbContext() { IDbContext dbContext = new IDbContext(() => CreateNewContext()); return dbContext; } private MyObjectContext CreateNewContext() { return new MyObjectContext (\_dbConnectionString); }
}
Here IRepo Pattern comes into role as:
public partial interface IRepository<T> where T : BaseEntity
{
T GetById(object id);
}Now the Repository class implementing this Interface is as below :
public partial class EfRepository<T> : IRepository<T> where T : BaseEntity
{
private readonly Lazy<IDbContext> _dbContext;
private readonly IDbContextFactory _dbContextFactory;
private -
Why should I use Interface type of object in Constructor instead of Actual Class ObjectI've outsourced my enterprise level project to a freelancer and I got a quite good setup too. But now that contract has finished and the person has also moved to a new technology, in other words not willing to extend the contract. Now I'm looking into this code on myself. I do have a 2 3 years of background in C# and MVC. Below is a rough idea of my application architecture. Hopefully I've tried my best to abstract the architectural details of an enterprise level application. Please let me know if you need further brief on any of the questions. All my Entities are defined as C# POCO classes as:
public class Product : BaseEntity
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}Now I've a IDbContext like as :
public interface IDbContext : IDisposable
{
IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity;
}Base Entity is a Partial POCO class that each POCO entity is inheriting. Here is a class that implements this IDBContext as:
public class MyObjectContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
{
return base.Set<TEntity>();
}
}Now I've defined a IDbContextFactory that is responsible for providing the DBContexts as :
public interface IDbContextFactory
{
Lazy<IDbContext> CreateDbContext();
}The class implementing this IDBContextFactory interface is having below structure :
public class MyDbContextFactory : IDbContextFactory
{
public MyDbContextFactory(string dbConnectionString)
{
_dbConnectionString = Settings.DbConnectionString;
_dbContext = CreateDbContext();
}public IDbContext CreateDbContext() { IDbContext dbContext = new IDbContext(() => CreateNewContext()); return dbContext; } private MyObjectContext CreateNewContext() { return new MyObjectContext (\_dbConnectionString); }
}
Here IRepo Pattern comes into role as:
public partial interface IRepository<T> where T : BaseEntity
{
T GetById(object id);
}Now the Repository class implementing this Interface is as below :
public partial class EfRepository<T> : IRepository<T> where T : BaseEntity
{
private readonly Lazy<IDbContext> _dbContext;
private readonly IDbContextFactory