linqpad

Can I have an incrementing count variable in LINQ?

I want to do something like this: from a in stuff let counter = 0 select new { count = counter++, a.Name }; But I get a error telling me that counter is read only. Is there a way to do something similar to this, without declaring a variable outside of the query? Basically, I just want to show a count/index column in LINQPad (which is...

Generated SQL with PredicateBuilder, LINQPad and operator ANY

I previously asked a question about chaining conditions in Linq To Entities. Now I use LinqKit and everything works fine. I want to see the generated SQL and after reading this answer, I use LinqPad. This is my statement: var predProduct = PredicateBuilder.True<Product>(); var predColorLanguage = PredicateBuilder.True<ColorLanguage>();...

How to get LinqPad to work with "Dynamic Query"?

Dynamic Query is a single C# file you add to your project. Anyone know how to add this library so that it works with LinqPad? ...

How do I use LINQPad to do execute batch job?

I recently found that LINQPad can execute shell commands. Can someone show me an example how to use LINQPad queries to execute batch job? ...

LinqPad / Sqlite version info and foreign key support

I am using fabulous LinqPad and its Sqlite driver. 1) Is there a way to obtain Sqlite version information by executing say "select version"? 2) Which driver specific connection string should I use to enable foreign key support in Sqlite? ...

Returning value of static property from public instance property

I was just playing around with some code in LINQPad and managed to crash the program with a stackoverflow exception. I basically created a static property in a field and used a property to return the value from an instance. The getter of my instance property would return the value of the static field, but the setter would set itself. W...

Int[] Reverse - What does this actually do?

I was just having a play around with some code in LINQPad and noticed that on an int array there is a Reverse method. Usually when I want to reverse an int array I'd do so with Array.Reverse(myIntArray); Which, given the array {1,2,3,4} would then return 4 as the value of myIntArray[0]. When I used the Reverse() method directly on m...

LINQPad - Dump extension method - I want one!

Hi, LINQPad is amazing, particularly useful is the Dump() extension methods which renders objects and structs of almost any type, anonymous or not, to the console. Initially, when I moved to Visual Studio 2010, I tried to make my own Dump method using a delegate to get the values to render for anonymous types etc. It's getting pretty c...

In LINQPad can you access SYSOBJECTS using LINQ?

In LINQPad is there any way to access either the SYSOBJECTS table or the various INFORMATION_SCHEMA.xxx views using LINQ? I spend a lot of time searching through our huge company database for partial names as there are too many tables and Stored Procedures to remember the names of them all. I know I can enter and run SQL in LINQPad but...

How can I iterate over a collection of objects returned by a LINQ-to-XML query?

I've got this XML: <BillingLog> <BillingItem> <date-and-time>2003-11-04</date-and-time> <application-name>Billing Service</application-name> <severity>Warning</severity> <process-id>123</process-id> <description>Timed out on a connection</description> <detail>Timed out after three retries.</detail> </BillingI...

Linq with a long where clause

Is there a better way to do this? I tried to loop over the partsToChange collection and build up the where clause, but it ANDs them together instead of ORing them. I also don't really want to explicitly do the equality on each item in the partsToChange list. var partsToChange = new Dictionary<string, string> { {"0039", "Vendor A"}, ...

How does LinqPad support WCF Data Services?

LinqPad supports WCF Data Services. If you assign an URL, such as http://services.odata.org/Northwind/Northwind.svc/. It will list all available data objects and you can query them. I guess LinqPad generates all available data classes at run time by reflection.Emit. I am wondering who can show me to how to do so. Or maybe someone has d...

How to increase limit of graph in LINQPad?

Results shown in LINQPad are limited. If objects are deep nested, a red line is shown. I would like to increase a limit, so I can see more nested objects. Do you know how to do it? (I have not find that in options.) ...

Use LINQ to SQL results inside SQL Server stored procedure

Note: I'm not trying to call a SQL Server stored proc using a L2SQL datacontext. I use LINQPad for some fairly complex "reporting" that takes L2SQL output saved to an Array and is processed further. For example, it's usually much easier to do multiple levels of grouping with LINQ to Objects instead of trying to optimize a T-SQL quer...

Linqpad seemingly does not recognize implemented interface

I have a c# project GenericBusinessObject and a project WebRole, which uses GenericBusinessObject. WebRole has a BusinessObject Workitem, that implements the Interface method IFastSearchable.IndexDocument that is called from within GenericBusinessObject. Actually the WorkitemBusinesObject is declared in WebRole as GenericBusinessObject. ...

How can I use two different databases with Linq to SQL in Linqpad?

I'm starting out with Linq To SQL, fiddling around with Linqpad and I'm trying to duplicate a SQL script which joins on tables in separate databases on the same server (SQL Server 2008). The TSQL query looks approximately like this: using MainDatabase go insert Event_Type(code, description) select distinct t1.code_id, t2.desc from O...

.NET coding setup with needed to install SQL Server ? (VS2010 + Linqpad)

I was thinking of the minimum software I can install on my new dev machine. Has anyone tried codeing with just VS2010/Linqpad? The SQL Server is on another machine so then I would only need SSMS.. but then I think linqpad could replace that + help me with Linq queries.. But the problem seems to be I won't be able to CREATE SQL USERS w...

InvalidOperationException: No method 'Where' on type 'System.Linq.Queryable' is compatible with the supplied arguments.

Hi, (Code below has been updated and worked properly) There is dynamic OrderBy sample from LinqPad. What I want to do is just simply apply 'Where' rather than 'OrderBy' for this sample. Here is my code: IQueryable query = from p in Purchases //where p.Price > 100 select p; string propToWhere = "Price"; P...

LINQPad: How to get row count in a table using MetaTable type?

In LINQPad, I'm trying to print all tables in a database and row count in each of them: this.Mapping.GetTables().Select(o => new { TableName = o.TableName, RowCount = ? }) How the row count can be calculated? ...

DataContext for LINQ to SQLite via System.Data.Sqlite

I'm fairly new to LINQ and trying to find a more elegant way (other than ADO.Net) to query and manipulate data in a SQLite database. I'm using System.Data.SQLite and wondering if there is a DataContext class or a way to use DataContext class to work with SQLite. I believe LINQPad uses the same assembly for its SQLite/MySQL driver and wi...