Questions tagged [linq-query-syntax]

Language-Integrated Query is the name for a set of technologies based on the integration of query capabilities directly into the C# language.

Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language. Traditionally, queries against data are expressed as simple strings without type checking at compile time or IntelliSense support. Furthermore, you have to learn a different query language for each type of data source: SQL databases, XML documents, various Web services, and so on. With LINQ, a query is a first-class language construct, just like classes, methods, events.

Full Overview: https://learn.microsoft.com/en-us/dotnet/csharp/linq/index

86 questions
0
votes
1 answer

Navigational Property not materialized in Linq Query Syntax also Lazy Loading didnt work

Below is a join using linq: var query = from a in TableA join b in TableB on new { a.Id1, a.Id2 } equals new { b.Id1, b.Id2 } select a; var entities = query.ToList(); foreach(var item in entities) { …
0
votes
2 answers

Issues with .NET Linq statement

Linq and Query's syntax is one of my weakest skills. I'm having issues with getting the desired result. I have two tables/ collections. One is filled with DocumentTypes, the other with Notifications. These are the fields they hold that matter, I…
Robin
  • 2,704
  • 7
  • 30
  • 47
0
votes
1 answer

How to blend an if-else into linq query syntax statement

I have two collections. A collection of Notifications and a collection of Document types. I need to collect information about the both of them and add an extra field depending on something as well. However, I don't have a clue how to do this. I get…
Robin
  • 2,704
  • 7
  • 30
  • 47
0
votes
2 answers

LINQ query to show result of 2 tables

Here are my two tables BuyShare SoldShare and the result table i want from LINQ query is This result table contain companies name with there total buy and sold shares. So far I code is: var userHistoryAll = from buy in db.share_bought_history …
Junaid umar
  • 77
  • 1
  • 2
  • 13
0
votes
2 answers

convert foreach and if to linq queries

foreach (SchemaInfo db in SourceSchemaInfos) { foreach (SchemaInfo table in db.SchemaInfos) { foreach (SchemaInfo tablelist in table.SchemaInfos) { …
Kiruthika
  • 23
  • 5
0
votes
2 answers

Is LINQ-to-Object is a LINQ provider?

I have some confusion that, In Linq-to-Object we work in-memory data to execute LINQ query that is process by c# language. When i write a Linq query that is execute base on in-memory data why we use provider (LINQ-to-Object)?
Ariful Haque
  • 878
  • 9
  • 11
0
votes
1 answer

insert linq query in many to many relation in asp.net mvc

Hi guys I am facing a problem in asp.net mvc. I have two tables Users and Projects and third table which creates a many to many relation in them User_Project but when I imported the tables in visual studio there is no table of User_Project but I…
Hasan Mir
  • 121
  • 1
  • 2
  • 8
0
votes
2 answers

Pass list of object properties to be used to form a new object inside a LINQ query

Sounds a little complex but here is what I am trying to do: I am filtering certain properties of MyObject in List into a new LINQ object as: var filteredMyObjects = from r in myObjects select new { r.ComponentName, r.Group, r.Key }; The…
eYe
  • 1,695
  • 2
  • 29
  • 54
0
votes
3 answers

Why I am getting Null from this statement. Query Syntax in C#

This is not working. Returns Null to dept_list. var dept_list = ((from map in DtMapGuestDepartment.AsEnumerable() where map.Field>("Guest_Id") == 174 select…
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
0
votes
1 answer

IQueryable Where only class name is known

What I have: session.Query().First(); What I am trying to do: var className="Symptom" session.Query().First() Is it possible to do this in some way? If yes where to look because I've tried with Type.GetType etc, without…
Sebastian 506563
  • 6,980
  • 3
  • 31
  • 56
0
votes
1 answer

"Expression type 'NhDistinctExpression' is not supported by this SelectClauseVisitor." - with Query Syntax

Given the following expression, how do I go about getting a distinct list of venues, without getting that nasty "Expression type 'NhDistinctExpression' is not supported by this SelectClauseVisitor." error? public Dictionary
PKD
  • 685
  • 1
  • 13
  • 37
0
votes
2 answers

How to sum a single row with multiple columns in linq query

(from item in _dbEntities.Bills where item.Year == year select item).GroupBy(x => x.MonthID).Sum(x => x.Phone); I want to sum all utility bills month wise like January there are 4 bills electricity, phone, water,gas..…
Mike
  • 751
  • 2
  • 10
  • 25
0
votes
1 answer

Want to sum fee in query month wise

var TotalFee = (from item in _dbEntities.MonthlyFees where item.Year == DateTime.Now.Year && item.FeeStatus == true select item).GroupBy(x…
Mike
  • 751
  • 2
  • 10
  • 25
0
votes
1 answer

select all when variable is empty or null else select values filtered

My linq query to summarize something like - string CustomerID;// can be "ALL" or any value var itemlist = ( from itmhstry in context.ItemHistories join itm in context.Items on itmhstry.ItemID equals itm.ItemID into…
Murali Uppangala
  • 884
  • 6
  • 22
  • 49
0
votes
1 answer

Algorithm to create batches of Files

I have one directory where all files with their different version are available. Like, ABC.pdf ABC_1.pdf ....... XYZ.tif ..... XYZ_25.tif MNO.tiff I want to make n batches of m files as per used requirement. Suppose, in folder I have ABC.pdf to…
sapatelbaps
  • 484
  • 2
  • 8
  • 19