Questions tagged [objectquery]

59 questions
19
votes
1 answer

Repository / IQueryable / Query Object

I am building a repository and I've seen in many places 2 reasons not to expose IQueryable outside the repository. The first is because different LINQ providers could behave differently, and this difference should be contained within…
Dale K
  • 25,246
  • 15
  • 42
  • 71
15
votes
3 answers

JDBI using @bind for variables in queries inside quotes

I'm wondering if/how this is possible, if it is, I'm sure its a simple fix that I can't seem to figure out @SqlQuery("SELECT * FROM Table WHERE column LIKE '%:thingName%'") public Set getThings(@Bind("thingName", String…
user2441922
  • 153
  • 1
  • 4
12
votes
3 answers

How can i convert a DBQuery to an ObjectQuery?

I've got a DBQuery which converts to an IQueryable (this bit works fine). But then I'm trying to convert the IQueryable to an ObjectQuery .. which fails :- public void Foo(this IQueryable source) { // ... snip ... ObjectQuery
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
7
votes
3 answers

Serialize Linq Results directly to JSON

I'm developing a WebService that excecute linq to sql db and put the results into a VAR variable. Then I wanna serialize the result inside VAR to json format using javascript serializer (c#). Something like this: var sb= from p in ent.people…
Enricosoft
  • 869
  • 2
  • 10
  • 28
6
votes
3 answers

How can I convert IQueryable to ObjectQuery?

I'm trying to apply the advice in this post: Tip 22 - How to make Include really Include It suggests a workaround for ensure eager loading works in the Entity Framework (4.2). That workaround involves casting the IQueryable to an…
dommer
  • 19,610
  • 14
  • 75
  • 137
5
votes
4 answers

How to use ObjectQuery with Where filter separated by OR clause

Could somebody help me to answer how to rewrite raw SQL filter WHERE (...) OR (...) with ObjectQuery bilder, please? String queryRaw = "SELECT ls.LocaleName, ls.IsActive, ls.LocaleDescription " + "FROM RoutesEntities.Locales AS ls…
Anonymous
  • 1,823
  • 2
  • 35
  • 74
5
votes
1 answer

DbSet.Include() causes SELECT N+1 when used in extension method

I have an extension on IQueryable that allows passing in delimited string of property names which, when used causes query not to construct JOINs and effectively causes SELECT N+1 issue. What I noticed is that if I call native EF extension…
zam6ak
  • 7,229
  • 11
  • 46
  • 84
5
votes
3 answers

Entity SQL compare datetime without milliseconds

I'm trying to fetch some records from MSSQL DB using EntityObject with EntitySQL query. The field i'm using to filter is type of datetime. The generated query projected without millisecond, to the SQL Server returns nothing. When i'm adding the…
Tamir
  • 3,833
  • 3
  • 32
  • 41
4
votes
2 answers

EF Query Object Pattern over Repository Example

I have built a repository which only exposes IEnumerable based mostly on the examples in "Professional ASP.NET Design Patterns" by Scott Millett. However because he mostly uses NHibernate his example of how to implement the Query Object Pattern, or…
Dale K
  • 25,246
  • 15
  • 42
  • 71
3
votes
1 answer

Using Contains in ObjectQuery

Here is my situation: I've got a m:n-relation between artists and events. What I'm trying to do is to get a IQueryable containing only events that include a certain artist. I'm using a repository for my data access layer. Obviously the following…
3
votes
1 answer

Returning IQueryable vs. ObjectQuery when using LINQ to Entities

I have been reading when using LINQ to entites a query is of type IQueryable before it is processed but when the query has been processed, it's no longer an IQueryable, but an ObjectQuery. In that case, is it correct to write methods from my layer…
3
votes
1 answer

Entity framework - ObjectQuery return int property and assign it to variable

I need to get UserCarId(int) from this query and assign to int type variable. int UserCarId; Entities ctx = new Entities(); var query = from enq in ctx.UserCars.Include("aspnet_Users") where…
Alex
  • 177
  • 4
  • 11
3
votes
2 answers

ObjectQuery, passing datetime in Where clause filter

How to pass in Date Time value here? ObjectQuery _Query = ItemEntities.CreateQuery("Item"); _Query = _Query.Where("(it.StartDate >= 11/4/2009 5:06:08 PM)"); my sample code above does seem to work. even with this ObjectQuery _Query…
Juvil
  • 490
  • 12
  • 26
3
votes
1 answer

Using Query Builder Methods against DbContext

I would like to use the "Query Builder Methods" on my DbContext like following: using (var context = new MyDbContext()) { var query = context.MyEntities.Where("Id = @id", new ObjectParameter("id", 1)); } But it cannot resolve this specific…
hattenn
  • 4,371
  • 9
  • 41
  • 80
2
votes
2 answers

IQueryable returns null on invoking Count c#

I have a problem trying to get the count out of the following query: var usersView = PopulateUsersView(); //usersView is an IQueryable object var foo = usersView.Where(fields => fields.ConferenceRole.ToLower().Contains("role")); Where UsersView is…
Ryan
  • 265
  • 1
  • 6
  • 17
1
2 3 4