iqueryable

IList<T> to IQueryable<T>

I have an List and I'd like to wrap it into an IQueryable. Is this possible? ...

IQueriable<T> for objects with better than O(n) performance?

Are there any IQueriable implementaions for linq-to-objects that perform better than the default O(n) linear search performance that you get when calling myEnumerable.AsQueriable()? I've had a look at http://www.codeplex.com/i4o/ which has better performance, but seems to rely on using extension methods on IndexedCollection rather than ...

How to verify existence of a table with a given ID in a word doc in C# VSTO 3

I want to check for the existence of a table with a given ID in a word document in C# (VS 2008) Visual Studio Tools for Office (version 3). Obviously I can iterate through the document's Tables collection and check every ID, but this seems inefficient; the document will end up having a few dozen tables after I'm done with it, and while ...

Design Patterns using IQueryable<T>

With the introduction of .NET 3.5 and the IQueryable<T> interface, new patterns will emerge. While I have seen a number of implementations of the Specification pattern, I have not seen many other patterns using this technology. Rob Conery's Storefront application is another concrete example using IQueryable<T> which may lead to some new ...

[LINQ] EntitySet vs Table

In a LINQ to SQL class, why are the properties that are created from the foreign keys EntitySet objects, which implement IEnumerable, where as the objects on the DataContext are Table objects which implement IQueryable? EDIT: To clarify, here is an example that illustrates what I'm trying to understand. This example: ctx.Matches.Where(...

Sorting IQueryable by Aggregate in VB.net

Hello all, been searching for a quick example of sorting a IQueryable (Using Linq To SQL) using a Aggregate value. I basically need to calculate a few derived values (Percentage difference between two values etc) and sort the results by this. i.e. return rows.OrderBy(Function(s) CalcValue(s.Visitors, s.Clicks)) I want to call an exte...

How to add a new record to an IQueryable variable?

The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result. ...

NHibernate testing, mocking ISession

Hi, I am using NHibernate and Rhinomocks and having trouble testing what I want. I would like to test the following repository method without hitting the database (where _session is injected into the repository as ISession): public class Repository : IRepository { (... code snipped for brevity ...) public T FindBy<T>(Expressio...

Linq To Sql return from function as IQueryable<T>

Ok, I have managed to get the following working public IQueryable getTicketInformation(int ticketID) { var ticketDetails = from tickets in _context.tickets join file in _context.file_objects on tickets.ticket_id equals file.source_id where tickets.ticket_id == ticketID select new { tickets.ticket_id, tickets....

DataContractSerializer within LINQ to SQL expression?

Hi, I'm new to LINQ expressions and trying to get the following to work: public IQueryable<Models.Powerups.Powerup> GetPowerups(Guid userid) { return from p in dc.Powerups where p.UserId == userid select (Models.Powerups.Powerup) new DataContractSerializer(Type.GetType(p.Type, true)).ReadObject(new XmlTextReader(new StringRea...

Linq - sum child field value when child records query ganareted by diffrent func

Hi, I have order - items tables. so I want to display on some grid all the orders info including a col like total_items There is a premetive working way. like this: TotalQuantity = (from i in _db.ProposaItems where i.ProposaID == p.ProposaID select i) .Sum(q => q.Quantity) But this is not the way I want. I want to use 2 func...

Customizing IQueryable<T>

I'm trying to customize entities of my application to make them have a property referencing the DataContext that loaded them. I think the best way is to somehow create a class that implements the IQueryable and set the entity datacontext property in its GetEnumerator method. My question is, how can I use the Provider and Expression use...

How do you transfer the execution of a Expression created by an IQueryable object to a IEnumerable ?

In my code I'd like to make my repositories IQueryable. This way, the criteria for selection will be a linq expression tree. Now if I want to mock my repository in theorie this is very easy : just implement the interface of my repository (which is also a IQueryable object). My mock repository implementation would be only a in memory co...

Convert Dataset to IQueryable<T> or IEnumerable<T>

Since there is no Linq to DB2 yet (c'mon IBM!), and I want to deal with IQueryables or IEnumerables in my code, how would I convert a DataTable to an IQueryable? Or an IEnumerable? I have an interface and a class that matches the columns in the datatable... IQueryable<IMyData> GetAS400Data(..parameters..) { DataSet d = GetData(); ...

How to apply a function to an IQueryable instance?

I've begun playing a bit with implementing an IQueryable<T> datatype to query using LINQ. For example I've made a couple of functions like this (It is just a temporary detail that the extension method is not for the specific IQueryable implementation): public static IQueryable<T> Pow<T>(this IQueryable<T> values, T pow) { var e = Bi...

count VS select in LINQ - which is faster?

I'm using IQueryable<T> interfaces throughout my application and defer execution of SQL on the DB until methods like .ToList() I will need to find the Count of certain lists sometimes -without- needing to use the data in the list being counted. I know from my SQL experience that a SQL COUNT() is far less work for the DB than the equival...

Silverlight, EDM/LINQ, and WCF Web Service - How to pass collections to Silverlight

What is the proper way to pass an answer (a collection) back to Silverlight? For example, if I have a service application that sits on top of the Northwind sample database and the service has a method called GetEmployees(). What is the proper "thing" to pass back to Silverlight? An IQueryable ? Then considering the Async/Result casting...

C#, Linq2Sql: Is it possible to concatenate two queryables into one?

I have one queryable where I have used various Where and WhereBetween statements to narrow the collection down to a certain set. Now I need to add kind of a Where || WhereBetween. In other words, I can't just chain them together like I have up till now, cause that will work as an And. So, how can I do this? I see two possibilities: Cr...

Non generic IQueryable Enumeration Problem

Using dynamic linq (http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx) I run the query below which returns an IQueryable. On this result which is also an IEnumerable I am able to run a Count() however there is not ToList() to get the values. I can enumerate over them using a f...

Extension Method to assign value to a field in every item?

I could have sworn that there was an extension method already built for the Queryable class that I just can't find, but maybe I'm thinking of something different. I'm looking for something along the lines of: IQueryable<Entity> en = from e in IDB.Entities select e; en.ForEach(foo => foo.Status = "Complete"); en.Foreach() would essent...