Click here to Skip to main content
15,885,365 members

Sql QUERY converting to ENTITY framework

naveen pallela asked:

Open original thread
I am trying to convert the sql query to Entity framework.but i am not able to convert the nested query can some one help on this.
SQL
AND TMM100_ITEM.itm_int_id IN (SELECT A.itm_int_id FROM TMM500_ITEM_VENDOR A WITH (NOLOCK) WHERE A.mfg_int_id = 666)



My sql query
SQL
SELECT TMM100_ITEM.itm_ext_id
FROM TMM100_ITEM WITH (NOLOCK)
 JOIN TMM500_ITEM_VENDOR WITH (NOLOCK) ON TMM100_ITEM.itm_int_id = TMM500_ITEM_VENDOR.itm_int_id
AND TMM500_ITEM_VENDOR.vnd_rnk_no = 1
 JOIN TMM140_MANUF WITH (NOLOCK) ON TMM500_ITEM_VENDOR.mfg_int_id = TMM140_MANUF.mfg_int_id
 JOIN TAP300_VENDOR_MASTER WITH (NOLOCK) ON TMM500_ITEM_VENDOR.vnd_int_id = TAP300_VENDOR_MASTER.vnd_int_id
WHERE TMM100_ITEM.crp_int_id = 18
AND ISNULL(stk_ty_fg, 'S') <> 'C'
AND TMM100_ITEM.row_sta_cd = 'A'
AND TMM100_ITEM.itm_int_id IN (SELECT A.itm_int_id FROM TMM500_ITEM_VENDOR A WITH (NOLOCK) WHERE A.mfg_int_id = 666)


What I have tried:

Entitty framework

C#
var Query = (from t100 in context.TMM100_ITEM
                                 join t500 in context.TMM500_ITEM_VENDOR on t100.itm_int_id equals t500.itm_int_id
                                 join t140 in context.TMM140_MANUF on t500.mfg_int_id equals t140.mfg_int_id
                                 join t300 in context.TAP300_VENDOR_MASTER on t500.vnd_int_id equals t300.vnd_int_id
                                 where t100.crp_int_id == 18 && t100.stk_ty_fg != "C" && t100.row_sta_cd == "A" && t140.mfg_int_id == value && t500.vnd_rnk_no == 1 && t500.row_sta_cd == "A"
                                 select t100.itm_int_id);
Tags: SQL, Entity Framework

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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