Skip to main content

Questions tagged [linq]

Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. Please consider using more detailed tags when appropriate, for example [linq-to-sql], [linq-to-entities] / [entity-framework], or [plinq]

-3 votes
0 answers
27 views

Method does not translate to SQL when used in another method

Best regard. At this time we are carrying out a method that allows us to identify which data has been entered into a table and which has not. Because to do this within our logic, we must do a join, we ...
German David's user avatar
1 vote
1 answer
31 views

NHibernate - Problem with creating a custom Linq extension

I have such query in NH Linq: var query = _session .Query<Revision>() .Join( _session.Query<Document>(), rev => rev.Document, doc => doc, (rev,...
robocik's user avatar
  • 121
2 votes
2 answers
65 views

Will LINQ Any() ever enumerate without arguments?

Given the following: var nums = GetNums(); Console.WriteLine(nums.Any()); Console.WriteLine(string.Join(", ", nums)); static IEnumerable<int> GetNums() { yield return 1; ...
Amber Cahill's user avatar
0 votes
3 answers
93 views

ORDER strings with LINQ Orderby [duplicate]

Please consider this code: string str1 = "M"; // <---77 string str2 = "m"; // <---109 var list = new List<string>() {str1, str2}; list = list.OrderBy(a=>a).ToList()...
DooDoo's user avatar
  • 13.3k
0 votes
1 answer
32 views

C# - Dynamic predicate inside .Select() throws expection

I have next domain models: public class UserTask { public int Id { get; set; } public string Name { get; set; } // ... public virtual ICollection<TaskHistory> TaskHistories { get;...
Jivopis's user avatar
  • 542
0 votes
1 answer
32 views

How to check particular character present in it

Here is my code: using System; namespace HelloWorld { class Program { static void Main(string[] args) { string ContactEmail = "[email protected]"; ...
Pinky's user avatar
  • 71
0 votes
1 answer
43 views

how to show data in list from multiple join having lot of column of complex object/class

These are below tables. I can not modify it Brand Id Name IsRegisterd 1 ABC True 2 XYZ True Product Id Name BrandId Active Version 1 Soap ABC True 1.0 2 Soap ABC ...
Pinky's user avatar
  • 71
0 votes
1 answer
41 views

C# Entity Framework Core - Get Parent with filtered child collections

I have approximately next domain models: public partial class ParentEntity { public int Id { get; set; } public string Name { get; set; } = null!; public virtual ICollection<ChildA> ...
Jivopis's user avatar
  • 542
-2 votes
0 answers
46 views

Improving performance of contains method in ASP.NET MVC web application with large dataset

I have an ASP.NET MVC web application using C#, Visual Studio, and SQL Server. This is my code: if (!string.IsNullOrEmpty(Name)) { query = query.Where(x => x.PatientName.Contains(Name)); } The ...
hud. 's user avatar
  • 166
0 votes
1 answer
54 views

2 LINQ queries use the same joins. Is there a way to "factor out" the joins and gain a performance benefit?

Here are two example queries: var queryA = from t1 in context.T1 join t2 in context.T2 where tl.colA == desiredColAValue select new ObjectA(valuesFromQueryA) ; var queryB = ...
rob.loh's user avatar
  • 13
2 votes
2 answers
41 views

How to handle the possibility of expected null properties in a LINQ were clause?

Consider the following C# Code Fragment: public class Person { public int Id { get; set;} public string? Name { get; set;} public string? Description {get; set;} } List<Person>? ...
William Holmes's user avatar
0 votes
0 answers
71 views

How do I set SQL Provider in C# Linq

I changed the default collation of my SQL Server 2022 database (and all string objects that already existed) to Latin1_General_100_CI_AS_SC_UTF8. Unfortunately, LINQ to SQL seems unable to handle this ...
awba's user avatar
  • 1
-1 votes
1 answer
43 views

Insert prefix in a Xml string [duplicate]

I need to be able to write this Xml string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing" ...
Modest's user avatar
  • 13
1 vote
1 answer
58 views

C# linq Include OrderBy

I need some help sorting data by Included data. In the example below, I am returning a purchase order where I want to sort the purchase order line items by the line item id. return await context....
michael's user avatar
  • 35
-1 votes
1 answer
57 views

Equals method never called by LINQ expression [duplicate]

My data class: using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using static iText.StyledXmlParser.Jsoup.Select.Evaluator; ...
janci's user avatar
  • 403

15 30 50 per page
1
2 3 4 5
5774