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
1
vote
2 answers

Async method in query syntax

I learn with asp.net identity, async/await, and I have this problem: I have some function for IEnumerable list. This list I fill using query syntax and looks like this: private IEnumerable GetPersons(int categoryId)…
goldieJ
  • 105
  • 1
  • 10
1
vote
1 answer

Pre defined expressions in LINQ query sytax

Is it possible to use a previously defined expression in LINQ expressions with query syntax? I've created a contrived example to illustrate my question. var tabletTypes = new List { 2, 3 }; //I want to use this expression many…
Steven Wexler
  • 16,589
  • 8
  • 53
  • 80
1
vote
1 answer

How to count occurence of partly-matching words with VB.NET?

I am using VB 9.0 to split a text file and then count occurrences of the term . Supposing I want also to count occurrences of the same term in a different format, e.g.
user198934
  • 19
  • 1
  • 2
1
vote
1 answer

LINQ Query across Associations

I have an Entity Framework that is generated from my database. Within this database is a table called User_Security_Role that is composed of two fields: Employee_ID and User_Name. Both fields act as its primary keys and are also foreign keys. The…
1
vote
1 answer

Filtering Linq Query Correctly

I have this query that retrieves sales from a bunch of shops, and returns them as a list. On my report request screen, the user can filter by a number of ids - ShopOwnerId, ShopRegionId, ShopTypeCode, etc. My query is structured to get all sales…
109221793
  • 16,477
  • 38
  • 108
  • 160
0
votes
3 answers

LINQ to SQL "complex" select

I have Country=>Ligue=>Team(Name, Score) I need to select all team Name-Scores from a country. something like this, does not work ) query = from ligue in myCountry.Ligues, from team in ligue.Teams select name = team.Name, score =…
serhio
  • 28,010
  • 62
  • 221
  • 374
0
votes
1 answer

Linq that Aggregates distinct IDs

I am having trouble getting the correct Linq query for the following issue: I have a List<> of storypoints that contains the following data: ParentID TaskID Points -------- ------ ----------- 1 100 2 1 …
0
votes
2 answers

Get minimum available number in list of integers

How to get minimum available number in list of integers with LINQ? Number can not be lower than 10. List numbers = new List() { 10, 11, 12, 22, 23 }; I want to return 13 in this case. List numbers1 = new List() { 11, 12, 22, 23…
0
votes
4 answers

Using two Linq query in a single method

As shown in the below code, the API will hit the database two times to perform two Linq Query. Can't I perform the action which I shown below by hitting the database only once? var IsMailIdAlreadyExist = _Context.UserProfile.Any(e => e.Email ==…
Chandan Y S
  • 968
  • 11
  • 21
0
votes
3 answers

Get selected fields on a list using a LINQ query

I have an entity framework generated class like this. public partial class TBLM_PRODUCT { public string PRODUCT_CODE { get; set; } public string PRODUCT_DESC { get; set; } public string PRODUCT_ISBN { get; set; } public string…
ChathurawinD
  • 756
  • 1
  • 13
  • 35
0
votes
1 answer

Select list of objects using a LINQ query

I have an object list like this. Object is type of TBLM_PRODUCT this is the entity framework generated class for my database table TBLM_PRODUCT. My TBLM_PRODUCT class looks like this public partial class TBLM_PRODUCT { public string…
ChathurawinD
  • 756
  • 1
  • 13
  • 35
0
votes
3 answers

Linq query to get the records of a table without using an object of the table

I'm using entity framework 6 to develop my c# application. I have named my data model as Allocation model and I have a table called JobTable. My Database model class looks like this public partial class Allocation : DbContext { public…
ChathurawinD
  • 756
  • 1
  • 13
  • 35
0
votes
0 answers

LINQ query syntax Operand should contain 1 column(s)

I have the following LINQ code: var count = (from ad in AccelerometerData join ae in AccelerometerEvents on ad.AccelerometerDataId equals ae.AccelerometerData.AccelerometerDataId where ad.Device.DeviceId == journey.Device.DeviceId…
J86
  • 14,345
  • 47
  • 130
  • 228
0
votes
1 answer

What determines what the Where in a Linq statement is able to parse?

In the Where clause of a Linq statement, like this, var myClasses = (from b in db.MyRecords join p in db.People on b.PersonId equals p.PersonId join cse in db.Courses on b.CourseId equals cse.CourseId …
johnny
  • 19,272
  • 52
  • 157
  • 259
0
votes
2 answers

Is that a shorter way assigning properties with LINQ Query Syntax?

Say I have a list of an object with 30 properties (eg: Items) If I am using LINQ Query-Syntax to Join another object (eg: Store), it seems inevitable that i have to re-assign every property from the Item, right? For example: var temp = from a in…
zeroflaw
  • 554
  • 1
  • 11
  • 23