Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with enums in relational entity into UpdateFromQuery #30

Closed
nebre opened this issue Mar 15, 2017 · 5 comments
Closed

Error with enums in relational entity into UpdateFromQuery #30

nebre opened this issue Mar 15, 2017 · 5 comments
Assignees

Comments

@nebre
Copy link

nebre commented Mar 15, 2017

Hi,

When I try to filter from a relational enum, like this:

unitOfWork.Set<ClientContact>()
                    .Where(x => x.Client.Status == ClientsClientStatusEnum.Pending)
                    .UpdateFromQuery<ClientContact>(x => new ClientContact() { Code = "something" });

This try to update the Entity with this query:

exec sp_executesql N'MERGE INTO [Clients].[ClientContacts] AS DestinationTable
USING
(
SELECT 
    [Extent2].[StatusValue] AS [StatusValue], 
    [Extent1].[Id] AS [Id]
    FROM  [Clients].[ClientContacts] AS [Extent1]
    INNER JOIN [Clients].[Clients] AS [Extent2] ON [Extent1].[ClientId] = [Extent2].[Id]
    WHERE ([Extent2].[StatusValue] IN (3, 4))
) AS StagingTable
ON StagingTable.StatusValue = DestinationTable.StatusValue AND StagingTable.Id = DestinationTable.Id
WHEN MATCHED THEN
    UPDATE
    SET     [Code] = @zzzupdate_1
;',N',@zzzupdate_1 nvarchar(4)',@zzzupdate_1=N'something'

As you could show, it try to compare this enum into two different entities, because on stagingTable is from Clients and try to filter into ClientContacts

@JonathanMagnan JonathanMagnan self-assigned this Mar 15, 2017
@JonathanMagnan
Copy link
Member

Hello @nebre ,

Thank you for reporting this issue.

We will try to look at it and release a fix today.

More information will be available soon.

Best Regards,

Jonathan

@JonathanMagnan
Copy link
Member

JonathanMagnan commented Mar 16, 2017

Hello @nebre ,

The v3.11.4 has been released
https://www.nuget.org/packages/Z.EntityFramework.Extensions/

Could you try it and let us know if the issue is fixed?

Best Regards,

Jonathan

@nebre
Copy link
Author

nebre commented Mar 16, 2017

Hi again,

I try with this new version but I still have the problem, nothing different, sorry.

exec sp_executesql N'MERGE INTO [Clients].[ClientContacts] AS DestinationTable
USING
(
SELECT 
    [Extent2].[StatusValue] AS [StatusValue], 
    [Extent1].[Id] AS [Id]
    FROM  [Clients].[ClientContacts] AS [Extent1]
    INNER JOIN [Clients].[Clients] AS [Extent2] ON [Extent1].[ClientId] = [Extent2].[Id]
    WHERE (3 = [Extent2].[StatusValue])
) AS StagingTable
ON StagingTable.StatusValue = DestinationTable.StatusValue AND StagingTable.Id = DestinationTable.Id
WHEN MATCHED THEN
    UPDATE
    SET     [Code] = @zzzupdate_1
;',N'@zzzupdate_1 nvarchar(9)',@zzzupdate_1=N'something'

Could I check anything else?

@JonathanMagnan
Copy link
Member

Hello @nebre ,

You are right, we did a small (major) mistake in our fix.

The v3.11.6 has been released
https://www.nuget.org/packages/Z.EntityFramework.Extensions/

Could you try it and let us know if the issue is fixed this time ;) ?

Best Regards,

Jonathan

@nebre
Copy link
Author

nebre commented Mar 17, 2017

Perfect, works fine now, thanks a lot

@nebre nebre closed this as completed Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants