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

Query: Translate Contains #1243

Closed
yuezhongxin opened this issue Dec 7, 2014 · 5 comments
Closed

Query: Translate Contains #1243

yuezhongxin opened this issue Dec 7, 2014 · 5 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@yuezhongxin
Copy link

Test as follows:

Exception Details:

For more details see this blog: EntityFramework 7 Linq Contains In 奇怪问题

@rowanmiller
Copy link
Contributor

Worst case this should use client eval for the moment.

@maumar
Copy link
Contributor

maumar commented Dec 29, 2014

Client side support checked in - a2e689d
Will leave this open to track database side support.

@rowanmiller
Copy link
Contributor

Confirmed that this now translates, the generated SQL is

SELECT [b].[BlogId], [b].[Url]
FROM [Blog] AS [b]
WHERE [b].[Url] IN ('a', 'b', 'c')

@rowanmiller
Copy link
Contributor

@maumar just checking there was no other reason this was left open?

@rowanmiller rowanmiller modified the milestones: 7.0.0-rc2, 7.0.0 Dec 8, 2015
@rowanmiller rowanmiller changed the title Use EF7, Linq Contains In is error. Query: Translate Contains Dec 8, 2015
@gambit-monkey
Copy link

I just upgraded to EF7 Core 1.0 and I am trying to migrate some of my API 2.0 / EF 6 code over to the new version and most stuff is migrating OK, however the contains is not throwing an exception but no results are returned when a where clause has a contains in it. Is this still a bug?

My Old EF6 Code
string[] ocmDrugs = _genericDrugs.Concat(_brandDrugs).ToArray();

        List<AgentDTO> agents = (from drugs in db.xref_agt_pt
                                 where ocmDrugs.Contains(drugs.agt_name.ToUpper()) && drugs.status.ToUpper() != "I"
                                 select new AgentDTO
                                 {
                                     PatientID = drugs.pt_id.Trim(),
                                     Name = drugs.agt_name.Trim(),
                                     IsActive = drugs.status.Trim(),
                                     DateOrdered = drugs.date_of_last_dose,
                                     DateEnded = drugs.date_ended
                                 }).Distinct().OrderBy(o => o.DateOrdered).ToList();
        return agents;

My new EF7 Migration of this code
`string[] ocmDrugs = _optionsAccessor.GenericAgents.Concat(_optionsAccessor.BrandAgents).ToArray();

        var results = _context.XrefAgtPt
            .Where(drug => drug.Status.ToUpper() != "I" && ocmDrugs.Contains(drug.AgtName.ToUpper()));

        results.ToList();

        return Json(results);

Now if I take out the ocmDrugs.Contains(drug.AgtName.ToUpper()) piece then the code executes and returns results. If I leave it in there the code executes but returns no results. I have checked and yes the list contains elements and really have refactored this LINQ statement a bunch of different ways, but regardless any time I throw a contains into the mix I get nada.

Anyone have any ideas or is this just a bug still?

@ajcvickers ajcvickers removed this from the 1.0.0-rc2 milestone Oct 15, 2022
@ajcvickers ajcvickers added this to the 1.0.0 milestone Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests

6 participants