I need to perform a comparison between 2 lists of the same object and get the records that are different, but I can't find a way to project the result of the query in de last select .
In SQL the query would be the following
select * from actual a
join nuevo n
on a.d_codigo=n.d_codigo and a.id_asenta_cpcons = n.id_asenta_cpcons
where (
a.d_asenta <> n.d_asenta or
a.d_tipo_asenta <> n.d_tipo_asenta or
a.D_mnpio <> n.D_mnpio or
a.d_estado <> n.d_estado or
a.d_ciudad <> n.d_ciudad or
a.d_CP <> n.d_CP or
a.c_estado <> n.c_estado or
a.c_oficina <> n.c_oficina or
a.c_CP <> n.c_CP or
a.c_tipo_asenta <> n.c_tipo_asenta or
a.c_mnpio <> n.c_mnpio or
a.d_zona <> n.d_zona or
a.c_cve_ciudad <> n.c_cve_ciudad
)
En C# con sql el query seria el siguiente
var result = from a in actual
join n in nuevo
on new { a.d_codigo, a.id_asenta_cpcons } equals new { n.d_codigo, n.id_asenta_cpcons }
where !(a.d_asenta == n.d_asenta)
where !(a.d_tipo_asenta == n.d_tipo_asenta)
where !(a.D_mnpio == n.D_mnpio)
where !(a.d_estado == n.d_estado)
where !(a.d_ciudad == n.d_ciudad)
where !(a.d_CP == n.d_CP)
where !(a.c_estado == n.c_estado)
where !(a.c_oficina == n.c_oficina)
where !(a.c_CP == n.c_CP)
where !(a.c_tipo_asenta == n.c_tipo_asenta)
where !(a.c_mnpio == n.c_mnpio)
where !(a.d_zona == n.d_zona)
where !(a.c_cve_ciudad == n.c_cve_ciudad)
select ¿?;
In the microsoft documentation they show examples like the following one, in which in the last select they build a new object with the elements extracted from both lists
var q =
from c in db.Customers
join o in db.Orders on c.CustomerID equals o.CustomerID
into orders
select new { c.ContactName, OrderCount = orders.Count() };
Related
How to change this SQL query to LINQ? I've tried it several times, but it didn't work
SELECT Payment.ID, Payment.TotalGroupID, PaymentTrans.PaymentID, PaymentTrans.TotalGroupID as TotalGroupID1, PaymentTrans.TransferStatus
FROM PaymentTrans INNER JOIN Payment
ON (PaymentTrans.PaymentID = Payment.ID OR PaymentTrans.TotalGroupID = payment.TotalGroupID)
WHERE (PaymentTrans.TransferStatusis NULL OR (PaymentTrans.TransferStatus <> '01' and PaymentTrans.TransferStatus <> '02'))
and this is my try
var a= (from x in db.PaymentTransactions
join p in db.Payments
on
x.PaymentID equals p.ID
where x.TransferStatus== null || (x.TransferStatus!= "01" && x.TransferStatus!= "02")
select new { x, p }).ToList();
but it still wrong LINQ, because in my query I have 2 conditions in ON Clause. thanks
try this
var query = (from x in db.PaymentTransactions
join p in db.Payments
on x.PaymentID equals p.ID //main condition of join
where ((x.TransferStatus == null ||
(x.TransferStatus != "01" && x.TransferStatus!= "02")) //your `where` condition
|| x.TotalGroupID == p.TotalGroupID) //your second or join
select new {x,p})
.ToList();
The answers above filter on both conditions, they should filter one of the conditions according to the question (PaymentID or TotalPaymentID). You can either write two seperate queries and use a union or use a Cartesian product before filtering.
var result = (from paymentTransaction in db.PaymentTransactions
join payment in db.Payments on paymentTransaction.PaymentID equals payment.ID
where paymentTransaction.TransferStatus == null || (paymentTransaction.TransferStatus != "01" && paymentTransaction.TransferStatus != "02")
select new { paymentTransaction, payment }).Union
(from paymentTransaction in db.PaymentTransactions
join payment in db.Payments on paymentTransaction.TotalGroupID equals payment.TotalGroupID
where paymentTransaction.TransferStatus == null || (paymentTransaction.TransferStatus != "01" && paymentTransaction.TransferStatus != "02")
select new { paymentTransaction, payment });
var cartResult = from paymentTransaction in db.PaymentTransactions
from payment in db.Payments
where paymentTransaction.PaymentID == payment.ID || paymentTransaction.TotalGroupID == payment.TotalGroupID
where paymentTransaction.TransferStatus == null || (paymentTransaction.TransferStatus != "01" && paymentTransaction.TransferStatus != "02")
select new { paymentTransaction, payment };
You cannot add multiple ON in LINQ. the solution of your problem above can be solved like this.
Hint: just use multiple Where.
var result =
(
from trans in db.PaymentTransactions
join payment in db.payments
on trans.PaymentID equals payment.ID
where trans.TotalGroupID == payment.TotalGroupID
where x.TransferStatus== null || (x.TransferStatus!= "01" && x.TransferStatus!= "02")
select new
{
//your properties
}
).ToList();
I have this following query and want to convert to LINQ.
I have tried LINQPad and Linqer but getting an error in Visual Studio.
SELECT DISTINCT
g.TXT_Property,
up.TXT_Page
FROM MD g
LEFT JOIN MD ux ON ux.TXT_Page = #sPage
AND ux.TXT_Property = g.TXT_Property
AND ux.TXT_Product = #sProdAll
AND ux.GID_Section IS NULL
LEFT JOIN MD up ON up.TXT_Page = #sPage
AND up.TXT_Property = g.TXT_Property
AND (ISNULL(up.TXT_Product, '') = #sProd or up.TXT_Product = #sProdAlt)
AND up.GID_Section IS NULL
WHERE
(g.GID_Section IS NULL)
AND g.TXT_Page = #sPage
and (ISNULL(g.TXT_Product, '') = #sProd or g.TXT_Product = #sProdAlt or g.TXT_Product = #sProdAll)
ORDER BY TXT_Property, TXT_Product, TXT_Language
This what I have tried:
var query2 = from g in list
join ux in list
on g.Property equals ux.Property into g_ux
where ux.Page == sPage
&& ux.Product == sProdAll
&& ux.Section == null
And this is another try.
I have referred to
SQL to LINQ - multiple tables left outer join with where clause referring right table
// Another query
var query = (from g in
((from d in list
where ((d.Section == null || d.Section == uSection) && (d.Product == sProd || (sProd == "" && d.Product == null) || (d.Product == sProdAlt) || (d.Product == sProdAll)))
select (new { d.Property })).ToList())
join gx in
((from d in list
where (d.Section == null) && (d.Product == sProdAll)
select (new { d.Property, d.Page, d.Product, d.Language, d.Value, d.Section })).ToList())
on g.Property equals gx.Property into res1
from a1 in res1.DefaultIfEmpty()
join gp in
((from d in list
where (d.Section == null) && (d.Product == sProd || (sProd == "" && d.Product == null) || (d.Product == sProdAlt))
select (new { d.Property, d.Page, d.Product, d.Language, d.Value, d.Section })).ToList())
on g.Property equals gp.Property into res2
from a2 in res2.DefaultIfEmpty()
join ux in
((from d in list
where (d.Section == uSection) && (d.Product == sProdAll)
select (new { d.Property, d.Page, d.Product, d.Language, d.Value, d.Section })).ToList())
on g.Property equals ux.Property into res3
from a3 in res3.DefaultIfEmpty()
join up in
((from d in list
where (d.Section == uSection) && (d.Product == sProd || (sProd == "" && d.Product == null) || (d.Product == sProdAlt))
select (new { d.Property, d.Page, d.Product, d.Language, d.Value, d.Section })).ToList())
on g.Property equals up.Property into res4
from a4 in res4.DefaultIfEmpty()
orderby (new
{
TXT_Property = g.Property,
TXT_Product = Coalesce((Coalesce(a4.Page, "") == "" ? Coalesce(a4.Product, a3.Product) : Coalesce(a4.Product, "SA")), a3.Product, (Coalesce(a2.Page, "") == "" ? Coalesce(a2.Product, a1.Product) : Coalesce(a2.Product, "SA")), a1.Product),
TXT_Language = Coalesce(a4.Language, a3.Language, a2.Language, a1.Language),
})
select (new
{
TXT_Property = g.Property,
TXT_Product = Coalesce((Coalesce(a4.Page, "") == "" ? Coalesce(a4.Product, a3.Product) : Coalesce(a4.Product, "SA")), a3.Product, (Coalesce(a2.Page, "") == "" ? Coalesce(a2.Product, a1.Product) : Coalesce(a2.Product, "SA")), a1.Product),
TXT_Language = Coalesce(a4.Language, a3.Language, a2.Language, a1.Language),
TXT_Value = Coalesce(a4.Value, a3.Value, a2.Value, a1.Value)
}));
Your SQL query seems very questionable to me (since ux is a LEFT JOIN and (presumably) not referenced in the rest of the query, it adds nothing), and I had to assume the ORDER BY was on the g columns since it wasn't specified (and I am surprised that isn't rejected by SQL as ambiguous), but here is my try at the translation:
var ans = from g in MD
join ux in MD on new { TXT_Page = sPage, g.TXT_Property, TXT_Product = sProdAll, GID_Section = (string)null } equals new { ux.TXT_Page, ux.TXT_Property, ux.TXT_Product, ux.GID_Section } into uxj
from ux in uxj.DefaultIfEmpty()
join up in MD on new { TXT_Page = sPage, g.TXT_Property, GID_Section = (string)null } equals new { up.TXT_Page, up.TXT_Property, up.GID_Section } into upj
from up in upj.DefaultIfEmpty()
where up == null || (up.TXT_Product ?? "") == sProd || up.TXT_Product == sProdAlt
where g.GID_Section == null && g.TXT_Page == sPage &&
((g.TXT_Product ?? "") == sProd || g.TXT_Product == sProdAlt || g.TXT_Product == sProdAll)
orderby g.TXT_Property, g.TXT_Product, g.TXT_Language
select new { g.TXT_Property, up.TXT_Page };
Note: I put in the up == null because because otherwise the where might reject where the LEFT JOIN in SQL wouldn't.
I assumed the type of GID_Section was string, but you can cast the nulls to the right type.
Here is my SQL conversion recipe, though your SQL was a bit trickier since it combined LEFT JOIN and non-equijoin.
For translating SQL to LINQ query comprehension:
Translate FROM subselects as separately declared variables.
Translate each clause in LINQ clause order, translating monadic and aggregate operators (DISTINCT, TOP, MIN, MAX etc) into functions applied to the whole LINQ query.
Use table aliases as range variables. Use column aliases as anonymous type field names.
Use anonymous types (new { ... }) for multiple columns.
JOIN conditions that aren't all equality tests with AND must be handled using where clauses outside the join, or with cross product (from ... from ...) and then where
JOIN conditions that are multiple ANDed equality tests between the two tables should be translated into anonymous objects
LEFT JOIN is simulated by using into joinvariable and doing another from from the joinvariable followed by .DefaultIfEmpty().
Replace COALESCE with the conditional operator (?:)and a null test.
Translate IN to .Contains() and NOT IN to !...Contains(), using literal arrays or array variables for constant lists.
Translate x BETWEEN low AND high to low <= x && x <= high.
Translate CASE to the ternary conditional operator ?:.
SELECT * must be replaced with select range_variable or for joins, an anonymous object containing all the range variables.
SELECT fields must be replaced with select new { ... } creating an anonymous object with all the desired fields or expressions.
Proper FULL OUTER JOIN must be handled with an extension method.
i am trying to convert the following SQL into LINQ and need some assistance with the nested select clauses for the paid_amount and paid_vat and also for the select within the where clause. Ignore the index things.
here is the SQL
SELECT
tramps.gl_transaction.debtor_uri,
tramps.debtor.account_no,
tramps.gl_transaction.uri as transaction_uri,
tramps.gl_transaction.base_currency_amount,
tramps.gl_transaction.base_currency_vat_amount,
(select IsNull(sum(gltr.base_currency_amount), 0.00)
from tramps.gl_transaction gltr
where gltr.sibling_uri = tramps.gl_transaction.uri) * (-1) as Paid_Amount ,
(select IsNull(sum(gltr.base_currency_vat_amount), 0.00)
from tramps.gl_transaction gltr
where gltr.sibling_uri = tramps.gl_transaction.uri) * (-1) as Paid_Vat ,
tramps.account.property_ref,
tramps.account.sub_ledger_code,
tramps.gl_transaction.transaction_type_code,
tramps.gl_transaction.transaction_description,
tramps.gl_transaction.effective_date
FROM tramps.account, tramps.chart WITH (INDEX (PK_CHART)), tramps.gl_transaction WITH (INDEX (glt_debtor_gen)) ,tramps.debtor, tramps.receivables_register , tramps.bank_account
WHERE tramps.chart.code = tramps.account.chart_code
AND tramps.gl_transaction.debtor_uri = tramps.debtor.uri
AND tramps.gl_transaction.account_uri = tramps.account.uri
AND tramps.receivables_register.uri = tramps.gl_transaction.receivables_register_uri
AND tramps.receivables_register.bank_account_uri = tramps.bank_account.uri
AND tramps.chart.control_account = 'Debtor'
AND tramps.gl_transaction.status = 'L'
AND tramps.gl_transaction.process_status = 'Released'
AND ( (tramps.gl_transaction.generated = 'C' AND tramps.gl_transaction.sibling_uri IS NULL AND tramps.gl_transaction.written_off <> 'Y')
OR (tramps.gl_transaction.generated = 'N' AND tramps.gl_transaction.sibling_uri IS NULL) )
AND (tramps.gl_transaction.base_currency_amount +
(select IsNull(sum(gltr.base_currency_amount), 0.00)
from tramps.gl_transaction gltr
where gltr.sibling_uri = tramps.gl_transaction.uri) <> 0.00 )
this is the LINQ i have managed to create so far, but i am struggling with the nested selects, the sum and the where clause
from acc in Accounts
join chart in Charts on acc.Chart_code equals chart.Code
join gltrans in Gl_transactions on acc.Uri equals gltrans.Account_uri
join debt in Debtors on gltrans.Debtor_uri equals debt.Uri
join recreg in Receivables_registers on gltrans.Receivables_register_uri equals recreg.Uri
join bankacc in Bank_accounts on recreg.Bank_account_uri equals bankacc.Uri
let paidcurrency = from gltrns in Gl_transactions
where gltrns.Sibling_uri == gltrans.Uri
select gltrns.Base_currency_amount
where
chart.Control_account == "Debtor"
&& gltrans.Status == "L"
&& gltrans.Process_status == "Released"
&& acc.Property_ref == 102979
&& ((gltrans.Generated == "C" && gltrans.Sibling_uri == null && gltrans.Written_off != "Y")
|| (gltrans.Generated == "N" && gltrans.Sibling_uri == null) )
select new
{
gltrans.Debtor_uri,
debt.Account_no,
gltrans.Uri,
gltrans.Base_currency_amount,
gltrans.Base_currency_vat_amount,
er = (decimal?)paidcurrency.Base_currency_vat_amount.Sum() ?? 0,
acc.Property_ref,
acc.Sub_ledger_code,
gltrans.Transaction_type_code,
gltrans.Transaction_description,
gltrans.Effective_date
}
This might help out a little. I blended in some fluent syntax to help translate the Sum functions. Let me know if some of these translations help as I can't check it directly without your schema and some data.
var result =
from acc in Accounts
join chart in Charts on acc.Chart_code equals chart.Code
join gltrans in Gl_transactions on acc.Uri equals gltrans.Account_uri
join debt in Debtors on gltrans.Debtor_uri equals debt.Uri
join recreg in Receivables_registers on gltrans.Receivables_register_uri equals recreg.Uri
join bankacc in Bank_accounts on recreg.Bank_account_uri equals bankacc.Uri
// query expression
//let paidcurrency = from gltrns in Gl_transactions
// where gltrns.Sibling_uri == gltrans.Uri
// select gltrns.Base_currency_amount
// change to fluent..
let paid_Amount = gltrans.Where(g => g.Sibling_uri == g.Uri)
.Select(g => g.Base_currency_amount * -1 ?? 0.00M).Sum()
// same for Vat..
let paid_Vat = gltrans.Where(g => g.Sibling_uri == g.Uri)
.Select(g => g.Base_currency_vat_amount * -1 ?? 0.00M).Sum()
// added another 'let' to use in the where clause..
let base_Currency = gltrans.Where(g => g.Sibling_uri == g.Uri)
.Select(g => g.Base_currenct_amount ?? 0.00M).Sum()
where
chart.Control_account == "Debtor"
&& gltrans.Status == "L"
&& gltrans.Process_status == "Released"
&& acc.Property_ref == 102979
&& (
(
gltrans.Generated == "C" &&
gltrans.Sibling_uri == null &&
gltrans.Written_off != "Y"
)
||
(
gltrans.Generated == "N" &&
gltrans.Sibling_uri == null
)
)
&& gltrans.Base_currency_amount + base_Currency != 0.00M
select new
{
gltrans.Debtor_uri,
debt.Account_no,
gltrans.Uri,
gltrans.Base_currency_amount,
gltrans.Base_currency_vat_amount,
//er = (decimal?)paidcurrency.Base_currency_vat_amount.Sum() ?? 0,
paid_Amount,
paid_Vat,
acc.Property_ref,
acc.Sub_ledger_code,
gltrans.Transaction_type_code,
gltrans.Transaction_description,
gltrans.Effective_date
};
How can I do this CASE WHEN statement in LINQ ?
SELECT c.nm_grupo, c.cd_grupo, YEAR(GETDATE()),
CASE WHEN (
SELECT SUM(p.valor)
FROM ind_receita p
JOIN ind_equipto o ON p.cd_equipto = o.cd_equipto
JOIN ind_grupo c2 ON o.cd_grupo = c2.cd_grupo
WHERE c2.cd_grupo = c.cd_grupo
AND YEAR(p.dt_emissao) = YEAR(GETDATE())
)
IS NULL THEN 0 ELSE
(
SELECT SUM(p.valor)
FROM ind_receita p
JOIN ind_equipto o ON p.cd_equipto = o.cd_equipto
JOIN ind_grupo c2 ON o.cd_grupo = c2.cd_grupo
WHERE c2.cd_grupo = c.cd_grupo
AND YEAR(p.dt_emissao) = YEAR(GETDATE())
)
END AS valor
FROM ind_grupo c
ORDER BY c.nm_grupo
MY TRY
// SELECT * FROM IND_GRUPO IN LINQ
var GetAllGroups = (from c in _repositorio.GetGrupoEquipamentos()
select c);
// THE SAME SUBQUERY IN LINQ
var MySubQuery= (from p in _repositorio.GetReceitas()
join o in _repositorio.GetEquipamentos() on p.CodigoEquipamento.Equipamento_Id equals o.Equipamento_Id
join a in _repositorio.GetGrupoEquipamentos() on o.CodigoGrupo.Grupo_Id equals a.Grupo_Id
where p.DataHoraCriacaoRegistro.Year == DateTime.Now.Year
&& a.Grupo_Id == GetAllGroups.Select(a => a.Grupo_Id)
select p.Valor).Sum();
First, let's remove the CASE from your SQL: it can be replaced by ISNULL function:
SELECT
c.nm_grupo
, c.cd_grupo
, YEAR(GETDATE())
, ISNULL((
SELECT SUM(p.valor)
FROM ind_receita p
JOIN ind_equipto o ON p.cd_equipto = o.cd_equipto
JOIN ind_grupo c2 ON o.cd_grupo = c2.cd_grupo
WHERE c2.cd_grupo = c.cd_grupo
AND YEAR(p.dt_emissao) = YEAR(GETDATE())
)
, 0) AS valor
FROM ind_grupo c
ORDER BY c.nm_grupo
Now let's convert this to LINQ:
var GetAllGroups = _repositorio
.GetGrupoEquipamentos()
.Select(c => new {
c.nm_grupo // Use C# fields that you mapped to these fields in DB
, c.cd_grupo // Same as above
, valor = (from p in _repositorio.GetReceitas()
join o in _repositorio.GetEquipamentos() on p.CodigoEquipamento.Equipamento_Id equals o.Equipamento_Id
join a in _repositorio.GetGrupoEquipamentos() on o.CodigoGrupo.Grupo_Id equals a.Grupo_Id
where c.Grupo_Id == a.Grupo_Id && p.DataHoraCriacaoRegistro.Year == DateTime.Now.Year
select (decimal?)p.Valor).Sum() ?? 0
});
Note a cast of p.Valor to a nullable decimal. If you want a different type, replace this cast as appropriate.
Can this be converted to a single LINQ statement?
SELECT COUNT(*)
FROM Abstract_Dedications_Lookup
WHERE PlatEntryNumber = 10383772
AND CommonArea = 0
AND ((OuterType <> '' AND OuterValue <> '') OR (InnerType <> '' AND InnerValue <> ''))
AND ParcelNumber IN
(SELECT ParentParcelNumber
FROM Parcel_Title_History
WHERE EntryNumber <> 10383772
AND ParentParcelNumber <> '0'
AND ChildParcelNumber <> ParentParcelNumber)
I have tried many variations and can not get the correct syntax in the ".Contains" method. Can a "SELECT" be used within the "Contains"?
var query2 = from d in context.RTV_ParcelDedicationLocations
from p in context.RTV_ParcelTitleHistory
where d.PlatEntryNumber == PlatEntryNum
where d.CommonArea == false
where (d.OuterType != "" && d.OuterValue != "") || (d.InnerType != "" && d.InnerValue != "")
where d.ParcelNumber.Contains(p.ChildParcelNumber != p.ParentParcelNumber)
select d;
var results2 = query2.ToList();
You can create separate linq statements that will get executed by the database as 1 query. A linq statement dosent actually get execute until you begin to iterate over it.
The way I thought about this problem was to define a query that gets valid ParentParcelNumber from Parcel_Title_History. Then create another query that checks if the items in Abstract_Dedications_Lookup are in the first query. Try something like this:
var query1 = from p in context.RTV_ParcelTitleHistory
where p.EntryNumber != 10383772 & p.ParentParcelNumber != "0" & p.ChildParcelNumber != p.ParentParcelNumber
select p.ParentParcelNumber;
var query2 = from d in context.RTV_ParcelDedicationLocations
where d.PlatEntryNumber == 10383772
& d.CommonArea == 0
& ((d.OuterType != "" && d.OuterValue != "") || (d.InnerType != "" && d.InnerValue != ""))
& query1.Contains(d.ParcelNumber)
select d;
var results2 = query2.ToList();
The LINQ generated SQL statement below returns 44,092 records but should be same as the SQL in the OP which returns 182 records. Something in the query2 LINQ isn't correct apparently:
SELECT
[Extent1].[ParcelNumber] AS [ParcelNumber],
[Extent1].[PlatEntryNumber] AS [PlatEntryNumber],
[Extent1].[OuterType] AS [OuterType],
[Extent1].[OuterValue] AS [OuterValue],
[Extent1].[InnerType] AS [InnerType],
[Extent1].[InnerValue] AS [InnerValue],
[Extent1].[CommonArea] AS [CommonArea]
FROM (SELECT
[RTV_ParcelDedicationLocations].[ParcelNumber] AS [ParcelNumber],
[RTV_ParcelDedicationLocations].[PlatEntryNumber] AS [PlatEntryNumber],
[RTV_ParcelDedicationLocations].[OuterType] AS [OuterType],
[RTV_ParcelDedicationLocations].[OuterValue] AS [OuterValue],
[RTV_ParcelDedicationLocations].[InnerType] AS [InnerType],
[RTV_ParcelDedicationLocations].[InnerValue] AS [InnerValue],
[RTV_ParcelDedicationLocations].[CommonArea] AS [CommonArea]
FROM [dbo].[RTV_ParcelDedicationLocations] AS [RTV_ParcelDedicationLocations]) AS [Extent1]
WHERE (([Extent1].[PlatEntryNumber] = 10383772) AND (10383772 IS NOT NULL)
AND (0 = [Extent1].[CommonArea]) AND ('''' <> [Extent1].[OuterType]) AND ('''' <> [Extent1].[OuterValue]))
OR (('''' <> [Extent1].[InnerType]) AND ('''' <> [Extent1].[InnerValue])
AND ( EXISTS (SELECT 1 AS [C1]
FROM (SELECT [RTV_ParcelTitleHistory].[EntryNumber] AS [EntryNumber],
[RTV_ParcelTitleHistory].[ParentParcelNumber] AS [ParentParcelNumber],
[RTV_ParcelTitleHistory].[ChildParcelNumber] AS [ChildParcelNumber],
[RTV_ParcelTitleHistory].[Book] AS [Book],
[RTV_ParcelTitleHistory].[Page] AS [Page]
FROM [dbo].[RTV_ParcelTitleHistory] AS [RTV_ParcelTitleHistory]) AS [Extent2]
WHERE ( NOT (([Extent2].[EntryNumber] = 10383772) AND (10383772 IS NOT NULL))) AND ('0' <> [Extent2].[ParentParcelNumber]) AND ([Extent2].[ChildParcelNumber] <> [Extent2].[ParentParcelNumber]) AND ([Extent2].[ParentParcelNumber] = [Extent1].[ParcelNumber])
)))