Skip to content

Wrong EntityName in Generated SQL when an Expression is using a member defined in ancestor of the entity.  #12

Description

@bgiavottoatwork

Let's say one used a BaseEntity like this
public class BaseEntity
{
public string Id {get; set;}
}
and want to generate a SQL Expression for this Entity:
public class Derived: BaseEntity
{
public string AnotherField {get; set;}
}

Let's say we have to expressions:

a) Expression<Func<Derived, bool>> = (p)=>p.AnotherField = "A"
b) Expression<Func<Derived, bool>> = (p)=>p.Id = "A"

the former (A) gives, when traslated to SQL, something like "AnotherField = @p1" which is fine.
the latter (B) gives, when traslated to SQL, something like "[BaseEntity].Id = @p1" which is incorrect. it should be
"[Derived].Id = @p1"

Basically, when the SQL Expression is generated, the entity name should be the most derived class for a member name.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions