score:1
Accepted answer
Usually, the approach for filtering data like this is with cumulative query composition; for example:
IQueryable<PSearchModel> query =
from kb in db.kimlik_bilgileri
join dbilgi in db.dil_bilgisi on kb.id equals dbilgi.KimlikId
join okbil in db.okul_bilgileri on kb.id equals okbil.KimlikId
join kurbil in db.kurum_bilgileri on kb.id equals kurbil.KimlikId
join ens in db.enstitu on kurbil.kurum_id equals ens.id
join kadr in db.kadro_unvan on kurbil.kadro_id equals kadr.id
where kb.Aktifmi == true
select new PSearchModel
{
DilBilgisi = dbilgi,
// Diller = dil,
OkulBilgileri = okbil,
KadroUnvan = kadr,
Enstitu = ens,
KimlikBilgileri = kb,
KurumBilgileri = kurbil
};
if (!yabanciDil.IsNullOrWhiteSpace())
{
int dil_di = Convert.ToInt32(yabanciDil);
query = query.Where(o => o.DilBilgisi.dil_id == dil_di);
}
// ... add other filters here
var list = query.ToList();
This defers all execution to the end, and allows you to inspect dil_di
when debugging, to see if it is what you expect. If you still don't get what you expect, then you'll have to investigate what SQL is being issued, to see why your results are different from your expectations.
score:1
You could search in your List with LINQ as well. One possibility is this:
YourListObject.Where(c=>c.Test.Equals("Hallo"))
Also possible to Order or Group by equivalent to this.
Source: stackoverflow.com
Related Articles
- LINQ query filters not returning correct number of results
- Linq to SQL to return multiple counts from query not returning correct results
- Linq query with a Join, not returning the correct results
- How To Project a Line Number Into Linq Query Results
- LINQ to SQL query not returning correct DateTime
- linq query for varchar field not returning any results
- DateTime comparison in LINQ not returning correct results
- Why is this LINQ query not returning the correct dates?
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- LINQ query returns old results when source list is re-initialized
- Linq Query With Multiple Joins Not Giving Correct Results
- Why is sql server query returning results and linq query is not
- How do you write a LINQ query that filters a sub table to a specific time period and sums the results of the sub table?
- MS Graph - LINQ query returning incorrect results
- Returning results of LINQ query
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- LINQ query not returning the correct result
- Different Ways to Pull Number From Results View Of LINQ Query
- Returning the correct type in C# linq query over DataRows
- what LINQ query will return results based on partial matches against arbitrary number of an entity's fields?
- LINQ query doesn't give any results (finding which interval a number belongs to)
- LINQ query not returning expected results
- LINQ query returning null results
- LINQ query not returning results that I expect
- LINQ query returning no results
- Cannot get correct results from Linq query
- LINQ query is not returning expected results
- Linq query not returning expected results even when using DefaultIfEmpty
- Optional filters on LINQ Query returning unexpected result
- LINQ Query returning null results into anonymous variable
- Concatenate strings inside a linq 'select new object {
- build dynamic linq where from checked boxes
- List of Many-To-Many relationship EF Code-First
- How can I join a many to many relationship with linq
- Get all results in a IQueryable instead of .FirstOrDefault
- Simple Sequence Generation?
- restrict objects based on count of sub list in LINQ
- How do I select a collection within a collection using LINQ?
- How to group then select elements into new class in LINQ (C# preferably)
- C# Not able to use CopyToDataTable() function when grouping fields by LINQ & Datatable
- EF5 Select objects based on child collection content
- LINQ query bool value to pass in a different Int
- Count of files in C# with LINQ
- Need Linq expression explanation
- Entity Framework using Sqlite.NET complains that APPLY joins are not supported
- How do I get the departmentName alongside the employees first and last names in the combobox?
- How to remove duplicates (distinct values) with out primary key
- Comapring two List<String> to extract the common items and put it in List
- EF Code first - add collection to a collection, appropriate usage of skip() and take()
- Dynamic columns in DataGridView control (ASP.NET)