Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
253 views

I am trying to project the result of the following query into EF Core 8 entities: select foo.* , (case when hst.Id is not null and foo.OtherColumn = 1 then 42 else null end) as Bar ...
Ian Kemp - SO dead by AI greed's user avatar
1 vote
2 answers
143 views

How do I use Reverse to reverse the order of the results of a LINQ to Entities query? Something like: var result = dbContext.Users.Where(a => a.Name != null).Reverse();
Protector one's user avatar
2 votes
2 answers
116 views

Still on EF 6 "classic" (not core), when I do something like the following: var basicPersonList = myContext.Persons .Select(p => new PersonSimpleData { FamilyName = p....
lidqy's user avatar
  • 2,494
1 vote
1 answer
71 views

A rather complicated object mapping I've inherited uses static Expression<Func<...>> in the .Select call (from my research these seem to be called "Expression Trees", but for ...
C Howell's user avatar
1 vote
1 answer
45 views

I have this query in SQL: SELECT c.CompanyName, ( SELECT TOP 1 ct.CompanyTypeID FROM CompanyType AS ct WHERE ct.CompanyID=c....
Xiao Han's user avatar
  • 1,078
-1 votes
1 answer
105 views

I have a table ExerciseEnvironments with a unique constraint on a foreign key ExerciseId and type id TypeId combination, where a single exercise can have multiple unique environments but not multiple ...
jpro's user avatar
  • 364
0 votes
0 answers
33 views

One of the most common filters I apply to a query is to restruct the results to a single (business) organisation e.g. ctx.Users.Where(user => user.OrgID == orgID). I've created the following ...
Chris Walsh's user avatar
  • 3,523
0 votes
0 answers
72 views

We are moving from SQL Server to PostgreSQL. In SQL Server there is a datetimeoffset column type but in PostgreSQL this is not available, so we are splitting it into two columns. UTC datetime (...
Patrick Leijser's user avatar
0 votes
0 answers
60 views

I am trying to combine multiple LINQ expressions as an OR condition, so that they can be used in Entity Framework 4. The upgrade is not an option here. The VB code I have is: Public Function ...
Ricardo Peres's user avatar
-1 votes
2 answers
170 views

I'm working with EF Core 8 and the MySql provider (Pomelo) in my .NET project. I'm encountering a curious situation where the following code snippet runs without needing Dtos and doesn't produce the ...
Joseph's user avatar
  • 1,566
0 votes
1 answer
73 views

I have a filter class structure like this public class SchemeInvestorDataDateFilter { public int SchemeId { get; set; } public int InvestorId { get; set; } public DateTime Date { get; set; ...
Pawan Nogariya's user avatar
1 vote
1 answer
40 views

I am trying to write an EF6 LINQ query that takes a DateTimeOffset and retrieves all database entries that have a timestamp with the same local date as the given. The database has all timestamps as ...
RotundChinchilla's user avatar
0 votes
1 answer
313 views

I'm trying to create a Linq query that should work with a Contains on a string list. The following query works without errors with the SqlServer and PostgreSQL providers: IEnumerable<string> ...
SB_84's user avatar
  • 1
2 votes
2 answers
596 views

I have this ExecuteUpdate call below inside a for loop and I want to know if it's possible to eliminate the For loop and run ExecuteUpdate as one call? foreach (var registrant in yogabandEvent....
chuckd's user avatar
  • 14.8k
1 vote
0 answers
78 views

My repository class has a few methods for operations with the database. I recently developed the FindAsync() method, which allows you to grab only a few rows from the database based on an expression. ...
Sami Daniel's user avatar
2 votes
1 answer
91 views

Is there a way to make these 2 calls 1? Both are from the same table, just different values. var grossAmount = await _dbContext.StripeTransfers .Where(p => p.StripePayoutId == payout....
chuckd's user avatar
  • 14.8k
0 votes
0 answers
84 views

Here's a simplified version of what I'm doing: DateTime mydate = DateTime.Now; var myObject = db.Objects.First(); myObject.lastseen = mydate; db.SaveChanges(); var myobjects = mydb.Objects.Where(a=&...
user568551's user avatar
0 votes
0 answers
77 views

I am attempting to build a lambda from data. The module entity has an AlgNo property of type string. I am trying to get a simple sample code to run before attempting the more advanced case. Consider ...
Tormod's user avatar
  • 4,583
0 votes
1 answer
39 views

I apologize if this is stupid, but how to return an IEnumerable<Receipt> that contains Product in this case: // Each Receipt can have many ReceiptDetals public class Receipt { public int Id {...
Mario's user avatar
  • 28
1 vote
1 answer
223 views

I am using ASP.NET Core 8, Entity Framework and Linq to connect to a SQL Server database, but I am getting this error System.InvalidOperationException: the ConnectionString property has not been ...
user24241471's user avatar
0 votes
3 answers
71 views

I am working on ASP.NET Razor page LINQ to SQL function. I face issue I can't display distinct rows from result returned for viewmodel AssetLPOvm Desired result If I have 2 or 3 rows as sample exactly ...
ahmed elbarbary's user avatar
1 vote
2 answers
70 views

I have a database here in which, for reasons I cannot understand, the year and the month for the validity of an entry are stored in TWO separate fields... YearPart=2023 MonthPart=2 Now I need to ...
user1035681's user avatar
0 votes
1 answer
250 views

I'm trying to translate the following SQL-Select to LINQ to Entities and have a problem with an isnumeric check and hope that the community can give me a hint how to resolve it. select top(1) column1 ...
Patrick's user avatar
  • 17
-1 votes
1 answer
84 views

Having this enum : public enum MyEnums { A = 1, B = 2, C = 3, D = 4, E = 5 } If I create a list with some enum values from MyEnums for example this : IEnumerable<MyEnums> ...
user7849697's user avatar
2 votes
1 answer
106 views

I have the following classes: class Source { public int Id { get; set; } public string Name { get; set; } public SourceItem Item { get; set; } } class SourceItem { public Guid Id { ...
student0011001's user avatar
0 votes
1 answer
78 views

I have lots of tabular data that needs to be filtered, filtering is supposed to be available for each column in the data. The data is simple types, int, double, string, bool, date. Users specify the ...
PentagonalBishop's user avatar
4 votes
2 answers
183 views

Please consider this tables: Weight: City Weight -------------------- Tokyo 100 München 150 Köln 200 and Data: ID Country City Value ---------...
DooDoo's user avatar
  • 13.1k
0 votes
2 answers
93 views

My problem is a bit more complicated, so I have simplified it with the below example.   Let's say I have a simple list of Integers. I receive two condition input parameters in my function which tell ...
just-an-average-programmer's user avatar
0 votes
1 answer
101 views

I am trying to search contacts (Objects) that contains a List<Dictionary<string, string>> by a dictionary key and value Below is my Json Array of Contacts [ { "first_name": ...
Asana's user avatar
  • 3
0 votes
0 answers
120 views

I need some help converting below SQL into LINQ SELECT a.Id FROM ( SELECT s.student_id AS Id, COALESCE(l.city_name, '') AS City, ROW_NUMBER() OVER ( PARTITION ...
Kumar's user avatar
  • 1
0 votes
1 answer
119 views

I try to select a date field of two records in a MS SQL Server accounting database table. The first record's date is selected by id like this: var lastDate = db.Set<Accounting>().Where(p => p....
Helmut's user avatar
  • 502
0 votes
1 answer
235 views

I have a scenario where one Student (identified by StudentId) has many Courses. Each Course has StudentId(FK) and a Grade (simple text type). I want to build an IQueryable to pull 10 StudentIds (...
sarvpk's user avatar
  • 59
0 votes
1 answer
53 views

I have a table Person with firstname, last name, id. Another table with roles(string) for that person, another table with categories(string). these roles and categories are connected with Occupation ...
Lrn's user avatar
  • 3
2 votes
0 answers
61 views

I'm using the solution from this answer to form an Expression<Func<Proposal, bool>> object (where Proposal is an entity type in my app), according to the searching criteria input on a ...
Jyunhao Shih's user avatar
  • 1,478
0 votes
0 answers
164 views

I need to build an IQueryable<MyClass> in Linq and then obtain the actual SQL query (to be executed by another actor in my system). I get to grab the SQL statement using a method extension like ...
Rollersitch's user avatar
0 votes
1 answer
149 views

Original Question I have the following entity I’m trying to get to work with EF Core/NET7, where two properties map to the same column. This way either property could be used in various interfaces ...
Aaron's user avatar
  • 53
0 votes
1 answer
406 views

I'm trying to run a linq to entities query in EF Core 6, but I'm receiving an exception saying that System.Data.Entity.DbFunctions.CreateDateTime could not be translated. My goal is to filter a ...
Danilo Silva's user avatar
0 votes
0 answers
65 views

I need a little help in figuring out how I can fetch the location name of the student's home in the below scenario. These are entity framework entities. class Attendance { int Id; DateTime ...
user21996911's user avatar
0 votes
1 answer
390 views

I have two tables: Products and Files. The Products table contains a FK column photo_id that references the Files table. The Products table can also reference many files (pdf documents), with ...
Mario Peralta's user avatar
0 votes
1 answer
41 views

When using inheritence in Entity Framework, OfType<>() to filter a query to only include rows of the specific subclass. The resulting IQueryable is the type of the subclass. Is there a way to do ...
HEDGEWIZARDS's user avatar
1 vote
1 answer
50 views

I have a table that maps Products to Specs and SpecOptions and SpecUnits: MapProductSpecOptionSpecUnitSpec table: public class MapProductSpecOptionSpecUnitSpec { [Key, Column(Order = 0)] ...
Hooman Limouee's user avatar
1 vote
0 answers
29 views

Trying to join two tables on two substrings all while performing a cross apply: var thisQuery = ctx.Table1 .Join(ctx.Table2, t1 => t1....
BlueCardinal's user avatar
0 votes
2 answers
69 views

I have the below two entity classes in my application: class Attendance { public int Id {get; set;} public string StudentName {get; set;} // the linked entity public SubjectClass SubjectClass ...
user21996911's user avatar
0 votes
1 answer
93 views

Please consider this scanrio: I have a Master table: Id Country -------------------- 1 Ireland 2 Germany 3 Japan and Detials table: Id MasterId SellAmount ...
DooDoo's user avatar
  • 13.1k
1 vote
2 answers
681 views

I work on asp.net core razor page . I face issue How to convert complicated sql query to entity framework core 7 Exactly I need to convert this SQL statement to LINQ to entity without write SQL ...
ahmed abdelaziz's user avatar
1 vote
0 answers
58 views

I'm completely stuck on this simple query, made with Entity Framework Core 6 that should return a list of questions, counting the number of answers for each of them (it's like a forum...): questions = ...
Giox's user avatar
  • 5,183
2 votes
1 answer
107 views

I have the following structure: public interface IChainByPreviousId { int Id { get; set; } int? PreviousDeviceId { get; set; } } public class RegisteredDevice : IChainByPreviousId { ...
Oleg Sh's user avatar
  • 9,089
0 votes
2 answers
65 views

I have following classes class Patient { public string fname { get; set; } public string lname { get; set; } public IList<Letter> letter { get; set; } } class Letter { public ...
A. A.'s user avatar
  • 153
1 vote
1 answer
91 views

I am not seeing the expected SQL generated with regard to Distinct when selecting multiple columns. In particular the Distinct is being left out of the generated SQL. Strangely, this seems to work ...
Eric's user avatar
  • 2,420
1 vote
1 answer
65 views

I have a SQL Server database. In the orders table, I have a column for phone number. At the moment it contains different values like "+38 (453) 454-35-45", "0506070188", "+23 (...
Dmytro's user avatar
  • 33

1
2 3 4 5
138