Giter VIP home page Giter VIP logo

Comments (4)

GeertvanHorrik avatar GeertvanHorrik commented on June 25, 2024

Hi Galin,

Thanks for reporting. There are a few things happening in EntityRepositoryBase:

  1. It uses TEntity to determine the entity set name (see https://github.com/WildGums/Orc.EntityFramework/blob/develop/src/Orc.EntityFramework.Shared/Repositories/EntityRepositoryBase.cs#L49)

  2. It uses the `ObjectContext.CreateQuery(_entitySetName) to create the actual query (see https://github.com/WildGums/Orc.EntityFramework/blob/develop/src/Orc.EntityFramework.Shared/Repositories/EntityRepositoryBase.cs#L87)

Are you 100% sure that TEntity is the final class and that you defined it correctly on the DbContext?

from orc.entityframework.

lipchev avatar lipchev commented on June 25, 2024

It is a somewhat complex inheritance tree and I'm relatively new to EF but the generated classes seem to match my intentions- all but the concrete types are abstract. Note that the Entity Set Name in the designer is read-only, showing not the actual base class (which in my case is SUBSTANCE) but the one above ie MATERIAL (one would think this is because Substance is marked as abstract, but so is MATERIAL..). Here are my two concrete classes (in this branch):

        <EntityType Name="ChemElement" BaseType="CPA.Data.SUBSTANCE" />
        <EntityType Name="ChemCompound" BaseType="CPA.Data.SUBSTANCE" />

        <EntityType Name="SUBSTANCE" BaseType="CPA.Data.ChemEntity" Abstract="true">
        <EntityType Name="ChemEntity" BaseType="CPA.Data.MATERIAL" Abstract="true">
        <EntityType Name="MATERIAL" Abstract="true">

My DbContext defines the sets in partial class like so (probably unnecessary, maybe a way to do this in the designer?) :

        public virtual DbSet<ChemElement> ChemElements { get; set; }
        public virtual DbSet<ChemCompound> ChemCompounds { get; set; }

I've played a bit with the code from GetEntitySetName however none of my concrete types are found in the BaseEntitySets of the container and using their base type as fail-back I think puts us in the "get all scenario".
Furthermore, the initial reason for questioning the intended behavior of the RepositoryBase class was this message from the exception that is thrown when I attempt to do dbContext.GetEntitySet(entityType):

There are no EntitySets defined for the specified entity type 'CPA.Data.ChemElement'. If 'CPA.Data.ChemElement' is a derived type, use the base type instead.

So my thinking was- if there is no explicit OfType anywhere (that I could see)- there is no hope of getting the magical WHERE IsElement=1 clause in..
Anyway- it might just as well be that my model is buggy (as you can see I haven't even gotten to fixing the names yet) and I would hate to waste your time fixing my issues.. so in case what I'm describing is unit-tested somewhere else- maybe ignore this for a while- if the issue is on my side it will likely manifest itself somehow soon.. if not, I'll ping back once I'm confident that the model works 100%.
Anyway here's an extra screenshot from the debugger:
image

from orc.entityframework.

GeertvanHorrik avatar GeertvanHorrik commented on June 25, 2024

Ok, let's put this on hold so you can figure it out first. If you think you found a bug, please report back (re-open this ticket) with a repro and we will look into it.

from orc.entityframework.

lock avatar lock commented on June 25, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from orc.entityframework.

Related Issues (3)

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.