linq-to-entities Questions

3

I have this code: from pr in e.ProgramSetup.Include("Program").Include("Program.Client") where pr.DateBegin < DateTime.Now && pr.DateEnd > DateTime.Now.AddDays(pr.DateEndOffset) s...
Salomesalomi asked 1/10, 2012 at 13:0

9

Solved

I have a console application and what I'm trying to do is that every time the appllication runs, the date and time is sent to a table within my database. The table structure is like so: FTPRuns ...
Witherspoon asked 26/11, 2010 at 9:14

8

Solved

How do I change this query so it returns all u.usergroups? from u in usergroups from p in u.UsergroupPrices select new UsergroupPricesList { UsergroupID = u.UsergroupID, UsergroupName = u.Usergrou...
Southeaster asked 4/4, 2011 at 11:46

9

Solved

This isn't a case-sensitive comparison in LINQ to Entities: Thingies.First(t => t.Name == "ThingamaBob"); How can I achieve case sensitive comparison with LINQ to Entities...
Purpleness asked 1/10, 2010 at 21:7

3

Solved

I have a class representing a table on database that is defined: public class MyClass{ public int MyClassId{get;set;} public string Name{get;set;} public string LastNamw{get;set;} public Date...
Teteak asked 3/7, 2012 at 15:26

13

Solved

How do i return matching entities in a random order? Just to be clear this is Entity Framework stuff and LINQ to Entities. (air code) IEnumerable<MyEntity> results = from en in context.MyEn...
Kiyohara asked 17/3, 2009 at 16:6

3

Solved

I have a list of ints: var ids = new List { 10, 20 }; And I need to find Users with that ids: context.Users.FromSqlInterpolated($@" select Users.* where Users.Id in ({String.Join(',', ids)})...

3

I try to use the same select query multiple times in my application. For example I have this select statement: _db.tbl_itembundlecontents .Select(z => new SingleItemDTO { amount = z.amount,...
Inadvisable asked 9/11, 2015 at 10:54

5

Solved

I have the following LINQ query executed using Entity Framework (v6.1.1): private IList<Customer> GetFullCustomers(IEnumerable<int> customersIds) { IQueryable<Customer> fullCust...
Ambulant asked 10/8, 2014 at 11:58

4

Solved

I have a list of Products like this var r = db.Products.Where(x => x.Sites .Where(z => z.Key == associatedProducts.Key) .Any() ).ToList() There is an entity called Products, I want to g...
Kironde asked 4/2, 2013 at 7:41

6

Solved

In Entity Framework Core I have the following Entity: public class File { public Int32 Id { get; set; } public Byte[] Content { get; set; } public String Name { get; set; } } And I have a lis...
Eucharist asked 25/1, 2018 at 12:52

6

Solved

var result=(from refridgerators in context.A group refridgerators by new { refridgerators.Id, refridgerators.Name } into gr select new DAO<String> { Key = gr.Key.Name, Count = gr.Count(...
Pompadour asked 3/7, 2014 at 7:36

2

Solved

The below LINQ query works perfectly fine in EF6 world where the whole query seems to be evaluated at the server (checked with SQL Profiler) but fails in EFCore6. private IQueryable<CommentRespo...

5

Solved

include matchparticipants is not working. It always says Null when I debug. But when I put the GroupBy in comment it works fine. I am using Entity framework 4.3.1 with code-first. Entities: publi...
Morello asked 13/5, 2012 at 13:56

3

Solved

I try to add leading zeros in my ASP MVC application via Linq: int length = 4; IEnumerable<object> query = [...] select new { Seq = a.Seq.ToString("D" + length), }).OrderBy(a =>a.Seq)....
Fun asked 30/11, 2015 at 8:28

12

In using the EntityFramework, I get the error "A lambda expression with a statement body cannot be converted to an expression tree" when trying to compile the following code: Obj[] myArray = objec...
Vitus asked 3/3, 2011 at 10:17

5

Solved

I know some differences of LINQ to Entities and LINQ to Objects which the first implements IQueryable and the second implements IEnumerable and my question scope is within EF 5. My question is wh...

2

Solved

I'm writing some LINQ to fetch records based on an email, however, the generated SQL contains an additional IS NULL condition which doesn't need to be there because I am checking the parameter valu...
Waller asked 21/5, 2018 at 8:31

9

Solved

In T-SQL you could have a query like: SELECT * FROM Users WHERE User_Rights IN ("Admin", "User", "Limited") How would you replicate that in a LINQ to Entities query? Is it even possible?
Flessel asked 13/5, 2009 at 13:35

2

Solved

This has caused me no end of problems today. I have this simple query var result = DataContext.Accommodations.Where(a => (criteria.MinPrice == null || a.AccommodationRates.Any(r => r.From...
Germanous asked 5/9, 2012 at 15:10

15

Solved

I am having two date values, one already stored in the database and the other selected by the user using DatePicker. The use case is to search for a particular date from the database. The value pr...
Newfashioned asked 25/9, 2009 at 16:7

3

Solved

I use Asp.Net 4 and C#, I use EF 4. I have this query, I receive an error: An expression tree may not contain a dynamic operation dynamic o = e.Item.DataItem; var imagesContent = context.Cms...
Minestrone asked 19/8, 2011 at 7:56

7

Solved

var result = (from bd in context.tblBasicDetails from pd in context.tblPersonalDetails.Where(x => x.UserId == bd.UserId).DefaultIfEmpty() from opd in context.tblOtherPersonalDetails.Where(x =...
Terrell asked 20/7, 2012 at 18:4

3

Solved

I got this error when I was using "LINQ to entities" to show every single product and implement paging in ASP.NET MVC.: The method 'Skip' is only supported for sorted input in LINQ to Ent...
Trellis asked 2/4, 2014 at 3:20

9

Solved

I am using entities, C# and SQL Server to create an n-tier app. I am creating some base classes common to all my DAL components. In this base class, i want to handle the connection state of the Obj...
Extramarital asked 13/8, 2009 at 22:43

© 2022 - 2025 — McMap. All rights reserved.