iqueryable Questions

4

I'm trying to implement a caching scheme for my EF Repository similar to the one blogged here. As the author and commenters have reported the limitation is that the key generation method cannot pro...

2

Solved

It's common in C# to modify objects in private methods as they are commonly reference-types instead of value types, for example: public void Main() { var person = new Person(); SetPersonsName(p...
Looseleaf asked 20/10, 2014 at 10:14

7

Solved

I have some codes like below, I want to write unit tests my method. But I'm stuck in async methods. Can you help me please ? public class Panel { public int Id { get; set; } [Required] public d...

13

What is the difference between IQueryable<T> and IEnumerable<T>? See also What's the difference between IQueryable and IEnumerable that overlaps with this question.
Craze asked 31/10, 2008 at 7:18

7

Solved

I need to be able to either have an optional parameter in a Linq query, or be able to assign the query to a var in something like an IF if that optional parameter needs to be removed from the query...
Nitrosamine asked 21/2, 2013 at 1:24

5

Solved

I've been wrestling with this a little while and it's starting to look like it may not be possible. I want to Concat() two IQueryables and then execute the result as a single query. I tried someth...
Burrow asked 1/7, 2014 at 1:31

2

Solved

In EF6 I was used to doing this: var orders = GetAllEntities().Include(x => x.Contact.User); if (includeProducts) { orders = orders.Include(x => x.ProductOrders.Select(y => y.RentStockOr...
Kweichow asked 7/5, 2018 at 14:21

2

Solved

i have a function: private IEnumerable<Promotion> MatchesKeyword(IEnumerable<Promotion> list, String keyword) { ...snip... } which right now performs a LINQ query: private IEnumera...
Dinette asked 30/1, 2012 at 16:40

24

Solved

I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use a SQL-like string (e.g. OrderBy("Name, Age DESC")) for ordering. Unfortunately, the method included only ...
Lavender asked 3/9, 2008 at 6:30

24

Solved

I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use a SQL-like string (e.g. OrderBy("Name, Age DESC")) for ordering. Unfortunately, the method included only ...
Hawfinch asked 3/9, 2008 at 6:30

24

Solved

I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use a SQL-like string (e.g. OrderBy("Name, Age DESC")) for ordering. Unfortunately, the method included only ...
Troglodyte asked 3/9, 2008 at 6:30

4

Solved

Within the context of C# on .Net 4.0, are there any built-in objects that implement IQueryable<T>?
Penneypenni asked 7/2, 2012 at 1:38

6

Solved

When a method returns IEnumerable<T> and I do not have anything to return, we can use Enumerable.Empty<T>(). Is there an equivalent to the above for a method returning IQueryable<T&...
Alberta asked 22/4, 2010 at 13:54

3

Solved

I am getting runtime error This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code. Description: An unhandled exception occurred duri...
Eccentric asked 14/6, 2016 at 14:46

3

Solved

Lets say I have a simple repository class, with one GetByNames method public class MyRepo { private readonly MyDbContext _db; public MyRepo(MyDbContext db) { _db = db; } public IQueryable&l...
Nariko asked 23/10, 2015 at 14:59

5

Solved

We are trying to cast an instance of IQueryable<EntityObject> to an IQueryable<SpecificEntityObject>, the SpecificEntityObject type is only known at runtime. We have tried using the co...
Worshipful asked 11/1, 2012 at 12:7

2

Solved

This is my Custom filter(Func) to pass in where clause Func<Project,bool> filter = f => { bool filteredContent = true; if (!CreatorId.Equals(0)) filteredContent = f.CreatedBy.Equals(Cre...
Chidester asked 15/9, 2021 at 10:23

8

Solved

I need to be able to get something similar to the following to work: Type type = ??? // something decided at runtime with .GetType or typeof; object[] entityList = context.Resources.OfType<type...
Schluter asked 8/9, 2010 at 16:13

1

Solved

I am creating a query to cosmos using Linq This is converted into SQL which is then run to do the search var modelName = "Mondeo"; var baseQuery = client.CreateDocumentQuery<Car>(StaticSett...
Freezing asked 9/3, 2020 at 11:1

2

Solved

Any idea why the LINQ OrderBy is not working in following code, (have no errors but method does not sort ...) First my own type public class IQLinksView { public int id { get; set; } public in...
Frater asked 24/5, 2012 at 19:19

1

Most of the examples I see on the internet show the navigation properties as either ICollection or straight List implementation. They are usually virtual, to enable lazy-loading. However, when you...
Maccabean asked 6/1, 2017 at 16:36

5

Solved

I'm getting into using the Repository Pattern for data access with the Entity Framework and LINQ as the underpinning of implementation of the non-Test Repository. Most samples I see return AsQuerya...
Kirakiran asked 9/7, 2009 at 22:37

4

Solved

We've found that compiling our Linq queries is much, much faster than them having to compile each time, so we would like to start using compiled queries. The problem is that it makes code harder to...
Wean asked 3/8, 2009 at 18:7

5

I'd like to expose a Repository as an 'IQueryable' type. The repository uses Linq to NHibernate to communicate with the database. Can anyone point me at an example implementation? For example, w...
Electrostatics asked 14/7, 2010 at 13:44

4

Solved

I am currently ordering a list of custom objects using the IQueryable OrderBy method as follows: mylist.AsQueryable().OrderBy("PropertyName"); Now I am looking to sort by more than one p...
Penelopepeneplain asked 20/3, 2012 at 13:0

© 2022 - 2024 — McMap. All rights reserved.