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

Dynamic SQL Error SQL error code = -104 Token unknown AND - EF Core - Two or more *Where* parameters in LINQ to SQL [DNET926] #851

Closed
firebird-automations opened this issue Jan 15, 2020 · 3 comments

Comments

@firebird-automations
Copy link

Submitted by: Ryno (ryno_carbonsoft.co.za)

List<Document> documents = new List<Document>();

        var docs = \(from d in db\.Documents
                    where d\.DOCUMENT\_DATE \>= startDate & d\.DOCUMENT\_DATE <= endDate
                    select d\)\.ToList\(\);

        foreach \(Document doc in docs\)
        \{
            documents\.Add\(doc\);
        \}

        return documents;

RETURNS

SELECT "d"."DOCUMENT_ID", "d"."CLIENT_REF", "d"."CONVERSION_RATIO", "d"."CUSTOMER_CODE", "d"."DELIVERY_ADDRESS", "d"."DOCUMENT_DATE", "d"."DOCUMENT_TIME", "d"."DOC_NUMBER", "d"."DOC_STATUS", "d"."DOC_TYPE", "d"."EXCL", "d"."EXL_BIN", "d"."EXL_OVERREC", "d"."EXL_SURCHARGE", "d"."EXL_TRANSPORT", "d"."FINANCAIL_PERIOD", "d"."GROSSWEIGHT", "d"."INCL", "d"."INCL_BIN", "d"."INCL_OVERREC", "d"."INCL_SURCHARGE", "d"."INCL_TRANSPORT", "d"."INSTRUCTIONS", "d"."M3_QTY", "d"."MANUAL_NUMBER", "d"."OPTIONS", "d"."ORDER_NUMBER", "d"."PRICELIST_ID", "d"."PRODUCT_CODE", "d"."PRODUCT_UNIT", "d"."QTY", "d"."SUPPLIER_CODE", "d"."SURCHARGE_QTY", "d"."TRUCKTARE", "d"."VAT", "d"."VAT_CODE", "d"."VEHICLE_REG", "d"."ZONE_CODE"
FROM "DOCUMENT" AS "d"
WHERE (CASE
WHEN "d"."DOCUMENT_DATE" >= CAST(@__startDate_0 AS TIMESTAMP)
THEN TRUE ELSE FALSE
END AND CASE ---- ERROR
WHEN "d"."DOCUMENT_DATE" <= CAST(@__endDate_1 AS TIMESTAMP)
THEN TRUE ELSE FALSE
END) = TRUE

Which is invalid FB Sql

@firebird-automations
Copy link
Author

Modified by: Ryno (ryno_carbonsoft.co.za)

Component: Entity Framework Core [ 10160 ]

@firebird-automations
Copy link
Author

Commented by: @cincuranet

What's invalid about this SQL? A simpler version of this

SELECT *
FROM rdb$database
WHERE (CASE
WHEN 1 >= 1
THEN TRUE ELSE FALSE
END AND CASE ---- ERROR
WHEN 1 <= 1
THEN TRUE ELSE FALSE
END) = TRUE

works just fine.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants