Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
15 views

Dynamically create Entity,DbSet,Migration file,Migrator file and Tables

I want to dynamically generate the following components based on user input properties: Entity Class: Create a C# class representing the entity with properties based on user input. DbSet: Add a DbSet ...
Guna Krishnamoorthy's user avatar
0 votes
1 answer
26 views

C# Dictionary does not contain a definition for sum when using ulong [duplicate]

I have a Dictionary<string, DemoRecord> with DemoRecord having a field Size. I now want to calculate the sum of all sizes using LINQ. Here's the example public record DemoRecord(string Name, ...
Wouter Vandenputte's user avatar
1 vote
2 answers
33 views

Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type: decimal SSN, string FullName>>' to 'System.Collections.Generic.List<>

I got this error when I tried to make a method to return all users which have no users CS0029 Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type: decimal SSN, ...
Mohamed Fahmy's user avatar
-2 votes
0 answers
45 views

Select rows from database using dapper dynamic and reconstruct into custom object list in C# [closed]

I am fetching data from the database using Dapper as a dynamic list. ID ATTR ATTR_VALUE 1 A CAR 1 B BUS 1 C TRUCK 2 A CAR 2 B BUS 2 C TRUCK I have tried mapping the above dynamic data to the ...
shailesh M's user avatar
1 vote
1 answer
65 views

How to do an inner join?

I have an ASP.NET Core project where I am using Entity Framework to manage database queries. I want to know how I can do an INNER JOIN between two tables with Entity Framework, in this case the user ...
Daniel Rabelo's user avatar
0 votes
1 answer
24 views

How to create LINQ, that selects lists from list of lists that they contain all elements of any list from other list of lists?

I could not find or figure out similar LINQ example. For the example, I have 2 lists: List<List<string>> cases = new List<List<string>>() { new List<string>() { "...
bakunet's user avatar
  • 601
-3 votes
0 answers
43 views

Method does not translate to SQL when used in another method [closed]

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
2 votes
2 answers
69 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
99 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
33 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
42 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
49 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

15 30 50 per page
1
2 3 4 5
4441