Skip to content

How to use LinqKit in non static method? #197

Description

@hanzllcc

I have the IdentificationType class:

public sealed record IdentificationType
{
        public int Id { get; }
	public string Alias { get; }

	private IdentificationType(int id, string alias)
	{
                this.Id = id;
		this.Alias = alias;
	}

	public bool Equals(IdentificationType? left) => this.Alias == left?.Alias;

	public override int GetHashCode() => this.Alias.GetHashCode();
}

The property Alias is configured as Alternate key, and the Id as Primary key.
I want to use the Equals method in Ef core, in this way:

public Task<IdentificationType?> Find(IdentificationType identificationType) 
{
    return dbContext.IdentificationType
                    .AsExpandableEFCore()
                    .SingleOrDefaultAsync(i => i.Equals(identificationType));
}

When the Find method is invoked, Ef core uses Id instead of Alias.
How I could configure LinqKit to expand the Equals method?

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