Giter Club home page Giter Club logo

efprs's People

Contributors

fakhrulhilal avatar huynguyenqas avatar huyrua 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

Watchers

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

efprs's Issues

TPH inheritance and method GetAll

Hi. Thanks for sharing this.

I have a one problem. I'm using Table per Hierarchy (TPH).
For example we have a base class:

public abstract class Entity
    {
        public virtual int Id { get; set; }

        public virtual bool IsTransient()
        {
            return Id == default(int);
        }
    }

And base class for several entitites:

public abstract class Event:Entity
    {
        [MaxLength(50)]
        [Required]
        public string Name { get; set; }

        [Required]
        public string Description { get; set; }

        [Required]
        [MaxLength(100)]
        public string ShortDescription { get; set; }

        [Required]
        public DateTime PublishDate { get; set; }

        public int  Duration { get; set; }
    }

public class Film:Event
    {
        public string Director { get; set; }

        public string ActorList { get; set; }

        public override string ToString()
        {
            return Name;
        }
    }

public class Concert:Event
    {
        public string Genre { get; set; }

        public override string ToString()
        {
            return Name;
        }
    }

My context:

 public class MyContext:DbContext
    {
        public MyContext():base(ConfigurationManager.ConnectionStrings["MyContext"].ConnectionString)
        {
        }

        public DbSet<Event> Events { get; set; }

        public virtual void Commit()
        {
            base.SaveChanges();
        }

    }

Next, create context and repository:

var context = new MyContext();
EventRepository repository = new EventRepository(context);
 var films = repository.GetAll<Film>();

But I get exception: the sequence does not have elements. In this code:

string entitySetName = ((IObjectContextAdapter)DbContext).ObjectContext
                                                                     .MetadataWorkspace
                                                                     .GetEntityContainer(((IObjectContextAdapter)DbContext).ObjectContext.DefaultContainerName, DataSpace.CSpace)
                                                                     .BaseEntitySets.First(bes => bes.ElementType.Name == typeof(TEntity).Name).Name;

WebDbContextStorage in intergrated mode not working

Could you please help me with the following issue.

I have a web application using EF5 Code First with your Repository Pattern.
But when using the WebDbContextStorage like this in the Application_Start()

DbContextManager.Init("Default");
DbContextManager.InitStorage(new WebDbContextStorage(this));

When the app pool is running in Integrated Mode i recieve the following error message.

Object reference not set to an instance of an object.

when running in classic mode it is working fine.

When switching back to SimpleContextStorage it is also working fine for a single user.

Eager-Loading nav properties within the generic repo implementation?

Any particular reason to not include a way specify properties to eager load? Just wondering if there was something wrong with that.. I'm thinking I rather isolate all EF-specifics including the .Includes() calls to the same assembly as my generic repo implementation assembly.

I added params to GetQuery<>() and its overloads:

Queryable<TEntity> GetQuery<TEntity>(params Expression<Func<TEntity, object>>[] pExpandPropertySelectors) 

and before return the objectQuery:

if (pExpandPropertySelectors != null)
            {
                objectQuery = pExpandPropertySelectors.Aggregate
                    (objectQuery, (pCurrent, pInclude) => pCurrent.Include(pInclude) as ObjectQuery<TEntity>);
            }

also modified the GetByKey method to make a call out to DbContext.Entry(entityObject).Reference/Collection.Load() ..

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.