score:0
i currently have the same cases. i think the problem is the lack of recognition, by npgsql, of string.isnullorempty.
i replaced the test with a check on empty string, always recognizing as not null the input parameter.
-- bad
var data = from art in _ctx.set<soleo.model.dlar>()
from iva in _ctx.set<soleo.model.dlai>().where(k => k.ditta == art.ditta && k.cod == art.civa).defaultifempty()
from fam in _ctx.set<soleo.model.dlfa>().where(k => k.ditta == art.ditta && k.cod == art.fam).defaultifempty()
from mar in _ctx.set<soleo.model.dlma>().where(k => k.ditta == art.ditta && k.cod == art.mar).defaultifempty()
from udm in _ctx.set<soleo.model.dlum>().where(k => k.ditta == art.ditta && k.cod == art.um).defaultifempty()
where art.ditta == dlauth.config.current.ditta && art.cod.contains(sel_cod) && art.des.contains(sel_des)
&& (string.isnullorempty(sel_fam) || string.compare(art.fam, sel_fam, true) == 0)
&& (string.isnullorempty(sel_mar) || string.compare(art.mar, sel_mar, true) == 0)
&& (art.dis >= sel_dis_da && art.dis <= sel_dis_a)
select new
{
cod = art.cod,
des = art.des,
des_udm = udm.des,
des_mar = mar.des,
des_fam = fam.des,
des_civa = iva.des,
mag1 = art.mag1,
mag2 = art.mag2,
des_dis = art.dis == 1 ? "si" : "no"
};
-- good:
var data = from art in _ctx.set<soleo.model.dlar>()
from iva in _ctx.set<soleo.model.dlai>().where(k => k.ditta == art.ditta && k.cod == art.civa).defaultifempty()
from fam in _ctx.set<soleo.model.dlfa>().where(k => k.ditta == art.ditta && k.cod == art.fam).defaultifempty()
from mar in _ctx.set<soleo.model.dlma>().where(k => k.ditta == art.ditta && k.cod == art.mar).defaultifempty()
from udm in _ctx.set<soleo.model.dlum>().where(k => k.ditta == art.ditta && k.cod == art.um).defaultifempty()
where art.ditta == dlauth.config.current.ditta && art.cod.contains(sel_cod) && art.des.contains(sel_des)
&& (string.compare(sel_fam, "", true) == 0 || string.compare(art.fam, sel_fam, true) == 0)
&& (string.compare(sel_mar, "", true) == 0 || string.compare(art.mar, sel_mar, true) == 0)
&& (art.dis >= sel_dis_da && art.dis <= sel_dis_a)
select new
{
cod = art.cod,
des = art.des,
des_udm = udm.des,
des_mar = mar.des,
des_fam = fam.des,
des_civa = iva.des,
mag1 = art.mag1,
mag2 = art.mag2,
des_dis = art.dis == 1 ? "si" : "no"
};
but i do not think this is the solution. i will report the case to npgsql.
Source: stackoverflow.com
Related Query
- Include where clause on linq query when param is not null Npgsql
- Linq query works with null but not int? in where clause
- Linq query where First() appears to return null when results are not found
- LINQ OUTER JOIN Query - Null in Where clause not working
- Linq Where clause not returning what I expect when performing String.Contains(String) on a null string
- Where Clause is not applied when converting the query from LINQ (EF) to SQL
- LINQ: adding where clause only when a value is not null
- Linq Query with a Where clause in an Include statement
- Where clause not working on LINQ IQueryable query
- LINQ query null exception when Where returns 0 rows
- Check if List is not null when using "contains" in LINQ query else select all records
- How can I have a linq query conditionally NOT apply a where clause
- Filtering by Where clause only when condition is not null
- Where clause in LINQ query is not recognized in vb.net?
- Linq query NOT returning null when empty
- LINQ query - join and where clause not being obeyed?
- LINQ conditional where only when prop is not null
- How can I check for null values in this linq query where clause
- SQL to LINQ Query with date in where clause is not working
- Only include in where condition if value is not null in Linq
- Entity Framework Core Not Generating Where Clause When Using LINQ and predicate
- Left Join on Linq query when also using the Where clause on joint table
- Include null cells in Linq query from DB in C# code
- LINQ query dropping includes when adding `.Contains()` in where clause
- LINQ query performance when applying Where clause
- LINQ query returns null reference only after adding where clause
- LINQ to EF4 Query Where clause not filtering as expected
- Why is the Where clause in this LINQ Query not appending?
- LINQ query does not return any results when using with where condition
- LINQ Query with dynamic where clause based on search criteria that is NOT part of the returned object
More Query from same tag
- Faster way to get distinct values in LINQ?
- Executing stored procedure using linq in c#
- How to find duplicates in a dynamic list of lists in linq?
- Why does an IF Statement effect the outcome of my LINQ Statement?
- How to convert SQL with LEFT JOIN to EF CORE 3 LINQ
- linq/ef: How to form the query which connects multiple tables to return result?
- Sorting a list of objects based on another
- Storing XML in a nested dictionary
- Mapping Linq Query results to a DTO class
- Conditional select in SQL Statement
- Get Neighboring Entities
- How to update a particular field of a particular object in Generic list in c#.net using LINQ
- How does a LINQ expression know that Where() comes before Select()?
- Searching through multiple tables at once (Linq to SQL)?
- Subtract a generic list from another
- Combining Querys
- Linq result as collection of parent (User) object
- NHibernate - Select Random Number of Records with LINQ
- C# Linq - Given two lists, how do I tell if either of them are contained in each other
- Condense event list with LINQ
- Update IEnumerable<XElement> and save changes in XML document C#
- System.InvalidCastException. OK... Where?
- Is Lazy Loading really bad?
- Convert SQL - Linq with SQL IN
- Is there a difference between these two statements in Linq?
- LINQ - UNION - remove duplicated based on a single column
- flat list object into view
- Linq iterate a control collection
- How to create an InvocationExpression without parameters
- linq join 3 tables with or condition