linqpad

LINQPad script directory?

放肆的年华 提交于 2019-12-03 02:03:12
Does anyone know how to get hold of the path to the directory where the LINQPad script file (.linq) resides? Or to the script itself for that matter. Note that I'm not talking about the location of the "My Queries" folder, the one shown inside LINQPad. I can save a .linq file anywhere on disk, and open it by double-clicking on it. For instance, if I save the file to C:\Temp\Test.linq , and execute the program, I'd like to have either C:\Temp or C:\Temp\Test.linq . Basically I'd like something akin to Environment.CurrentDirectory or Assembly.GetEntryAssembly().Location , just for the .linq file

Steps for a beginner to run very basic linq to sql query using Linqpad

痞子三分冷 提交于 2019-12-02 23:11:54
Trying to learn Linq using LinqPad and getting frustated with how to start on it. Let's say I want to write a C# Expression and a C# statment where I have a table in SQL server named Products and I want to pull all rows where price is greater then 50. How would yo write it? Let's say I want to write a C# Expression and a C# statment where I have a table in SQL server named Products and I want to pull all rows where price is greater then 50. How would yo write it? LINQPad builds the typed DataContext for you automatically, so you don't need to instantiate anything. In C# expression mode, just

How to submit changes in LinqPad

泄露秘密 提交于 2019-12-02 21:47:34
I have a problem with committing changes in LinqPad. I am using Oracle database over IQ driver in LinqPad. I can retrieve data but I don't know how to submit changes to database. I retrieve data from database: var items = Asyncqueue.Where(x => ids.Any(y=> y == x.Asyncqueueid)); // then I have to fix data I have tried to set submit action like this: Asyncqueue.SetSubmitAction(items, SubmitAction.Update); Erwin Change Language in LINQPad to "C# Program" and use the following code void Main() { var p1 = Person.Single(x => x.Id == 1); p1.Name = "Test"; SubmitChanges(); } If you are using an EF

How does LINQPad reference other classes, e.g. Books in the LINQ in Action samples

老子叫甜甜 提交于 2019-12-02 17:24:11
I'm using LINQPad to create LINQ queries in an application I'm bulding. I noticed that in the downloaded LINQ in Action samples, e.g. example 4.04, intellisense shows a class "Books" but I don't see any references or " using " statements in the LINQPad tool, here is the sample: List<Book> books = new List<Book>() { new Book { Title="LINQ in Action" }, new Book { Title="LINQ for Fun" }, new Book { Title="Extreme LINQ" } }; var titles = books .Where(book => book.Title.Contains("Action")) .Select(book => book.Title); titles.Dump(); In "LinqBooks.Common, Business Objects, Book.linq " is where the

Why is my table not being created?

∥☆過路亽.° 提交于 2019-12-02 17:21:30
问题 I've got this code in my Winforms app to create a table in an existing database, (which I created by following what is written here): private void CreateTables() { string connStr = @"Data Source= (LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory| \AYttFM.mdf;Integrated Security=True"; using (var connection = new System.Data.SqlClient.SqlConnection(connStr)) { try { connection.Open(); using (var command = connection.CreateCommand()) { StringBuilder sb = new StringBuilder(); sb.Append(

Why is my table not being created?

强颜欢笑 提交于 2019-12-02 08:32:02
I've got this code in my Winforms app to create a table in an existing database, (which I created by following what is written here ): private void CreateTables() { string connStr = @"Data Source= (LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory| \AYttFM.mdf;Integrated Security=True"; using (var connection = new System.Data.SqlClient.SqlConnection(connStr)) { try { connection.Open(); using (var command = connection.CreateCommand()) { StringBuilder sb = new StringBuilder(); sb.Append("CREATE TABLE [dbo].[AssignmentHistory] "); sb.Append("("); sb.Append("[Id] INT NOT NULL PRIMARY KEY, ");

CancellationTokenSource.CancelAfter not working

不想你离开。 提交于 2019-12-01 21:57:12
I'm trying to implement some retry logic base on this post (but with tasks) Cleanest way to write retry logic? The idea for the retry logic is to then to implement a second task that triggers the cancelation after a give amount of time void Main() { RetryAction(() => Sleep(), 500); } public static void RetryAction(Action action, int timeout) { var cancelSource = new CancellationTokenSource(); cancelSource.CancelAfter(timeout); Task.Run(() => action(), cancelSource.Token); } public static void Sleep() { System.Threading.Thread.Sleep(5000); "done".Dump(); } The above is a linqPad snippet (thus

Can I remove a namespace import from a linqpad query?

非 Y 不嫁゛ 提交于 2019-12-01 18:20:16
I am trying to run a linqpad query, but one of the default namespace imports has a type that is apparently shadowing the type I am trying to reference. System.Xml is one of the default imports in linqpad, but I rarely use it. Is it possible to remove that default namespace import, so I can use my own Formatting enum? This isn't a direct answer to your immediate question, but you can can tell LINQPad which one you want Formatting to mean. In your query, press the F4 key and then under the Additional Namespace Imports tab you can add the following: Formatting = Newtonsoft.Json.Formatting This

LINQPad - can you run a linqpad script from the command-line?

风格不统一 提交于 2019-12-01 17:24:11
Is there a way to run a LINQPad script from the command-prompt (no gui)? If so, LINQPad would be handy for scripting C# and calling it from an automated build. lprun from LinqPad has already arrived: http://www.linqpad.net/lprun.aspx Yes, as of LINQPad v4.45.05 : LINQPad.exe "c:\path\to\my\script.linq" -run To close the LINQPad window, be sure to call this at the end of your script: Process.GetCurrentProcess().CloseMainWindow(); The ability to run LINQPad scripts from the command lines was just added in beta version 4.47 Full documentation on the new lprun.exe utility is available on: http:/

Generated SQL with PredicateBuilder, LINQPad and operator ANY

一笑奈何 提交于 2019-12-01 11:14:01
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>(); predProduct = predProduct.And(p => p.IsComplete); predColorLanguage = predColorLanguage.And(c => c.IdColorEntity.Products.AsQueryable().Any(expr)); ColorLanguages.Where(predColorLanguage).Dump(); The code works in VS2008, compile and produce the correct result