LINQ - Multiple Not Exists
-
Guru's I need your help. I've been trying to figure out how to write the following SQL code in VB.NET LINQ but haven't had any luck. Any suggestions would be appreciated: SELECT t.CUSTOMER_ID,t.INVOICE_NUMBER,t.INVOICE_DATE,t.GROSS_AMOUNT_DUE,t.DUE_DATE FROM ARN_1 t WHERE RECORD_TYPE = '1' AND NOT EXISTS(SELECT INVOICE_NUMBER FROM ARN t1 WHERE t1.INVOICE_NUMBER = t.INVOICE_NUMBER AND t1.RECORD_TYPE = '7') AND NOT EXISTS (SELECT INVOICE_NUMBER FROM ARN_1 t2 WHERE t2.INVOICE_NUMBER = t.INVOICE_NUMBER AND t2.RECORD_TYPE = '5') AND t.DUE_DATE < '2017-11-13'
MB
-
Guru's I need your help. I've been trying to figure out how to write the following SQL code in VB.NET LINQ but haven't had any luck. Any suggestions would be appreciated: SELECT t.CUSTOMER_ID,t.INVOICE_NUMBER,t.INVOICE_DATE,t.GROSS_AMOUNT_DUE,t.DUE_DATE FROM ARN_1 t WHERE RECORD_TYPE = '1' AND NOT EXISTS(SELECT INVOICE_NUMBER FROM ARN t1 WHERE t1.INVOICE_NUMBER = t.INVOICE_NUMBER AND t1.RECORD_TYPE = '7') AND NOT EXISTS (SELECT INVOICE_NUMBER FROM ARN_1 t2 WHERE t2.INVOICE_NUMBER = t.INVOICE_NUMBER AND t2.RECORD_TYPE = '5') AND t.DUE_DATE < '2017-11-13'
MB
Sorry, but your query looks ugly and probably is inefficient... First of all, the query you provided is "asking" your database (ARN_1 table) 3 times! You have to re-think your sql statement. There must be shortest (easiest) way! Secondly, you did not provide a linq version and did not provide why you had no luck till this moment. Please, edit your question and provide more details. A piece of input data and expected output might be helpful to understand your issue.