Skip to content

Varchar primary key not correctly quoted #240

Description

@arntj-bouvet

Hello,

we are currently working on a project using Trackable Entities for EF v6. We are currently using 2.5.7 (newest version).

In this project, we have two tables that are related to each other. The Main table has a foreign key to a type table.

The type table has a primary key of 2 columns.
Column 1 is smallint
Columns 2 is nvarchar(5)

We used Trackable Entities to track this relation. When running LoadRelatedEntities in EF6, we encountered the following exception:
bilde

('TRAKT' is a value, not a column name!)

We stepped through the code in VS, and stepped inside Trackable Entities code. What we found is as follows:
bilde

The key that is NVARCHAR isn't surrounded with single quotation marks.

Then, inside GetWhereSql, it is inserted without quotation marks:
bilde

The where clause we end up with is then:
bilde
WHERE (x.FirmaID = 10 AND x.KjoretoyType = TRAKT)

when it should be:
WHERE (x.FirmaID = 10 AND x.KjoretoyType = 'TRAKT')

This leads to an exception as the SQL isn't correctly shaped.

Again, this happens when the newest version (2.5.7) is installed with Nuget.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions