Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have following table

itemstatus(id, itemcode, itemstatus) with values

1,E123, Expired
2,E123, ReturnedToAgency
3,E124, Expired
5,E125, Delivered
5,E126, Expired
5,E127, Stored
5,E128, Expired
5,E129, Expired
5,E129, REturnedToAgency
5,E130, Delivered

from this, I want to fetch the itemcode with item status "Expired" but it doenst have row with "returned toagency". From the above table, it should show E126, E128. and it should not show E123,E124,E129 because its has also has rows with status "Returned To Agency".

How can write an entity framework query to fetch this

Please help me


1 solution

Try this

Dim query = From i1 in itemstatus
            Where i1.itemcode = "Expired" And
                Not (From i2 in itemstatus
                     Where i1.itemcode = i2.itemcode And
                        i2.itemstatus = "ReturnedToAgency").Any
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900