linqpad

What state is saved between rerunning queries in Linqpad?

无人久伴 提交于 2020-02-28 04:05:38
问题 What state is saved between rerunning queries in Linqpad? I presumed none, so if you run a script twice it will have the same results both time. However run the C# Program below twice in the same Linqpad tab. You'll find the first it prints an empty list, the second time a list with the message 'hey'. What's going on? System.ComponentModel.TypeDescriptor.GetAttributes(typeof(String)).OfType<ObsoleteAttribute>().Dump(); System.ComponentModel.TypeDescriptor.AddAttributes(typeof(String),new

What state is saved between rerunning queries in Linqpad?

半城伤御伤魂 提交于 2020-02-28 04:04:51
问题 What state is saved between rerunning queries in Linqpad? I presumed none, so if you run a script twice it will have the same results both time. However run the C# Program below twice in the same Linqpad tab. You'll find the first it prints an empty list, the second time a list with the message 'hey'. What's going on? System.ComponentModel.TypeDescriptor.GetAttributes(typeof(String)).OfType<ObsoleteAttribute>().Dump(); System.ComponentModel.TypeDescriptor.AddAttributes(typeof(String),new

What state is saved between rerunning queries in Linqpad?

倖福魔咒の 提交于 2020-02-28 04:02:01
问题 What state is saved between rerunning queries in Linqpad? I presumed none, so if you run a script twice it will have the same results both time. However run the C# Program below twice in the same Linqpad tab. You'll find the first it prints an empty list, the second time a list with the message 'hey'. What's going on? System.ComponentModel.TypeDescriptor.GetAttributes(typeof(String)).OfType<ObsoleteAttribute>().Dump(); System.ComponentModel.TypeDescriptor.AddAttributes(typeof(String),new

Sort by New Guid for random order

送分小仙女□ 提交于 2020-01-23 08:04:21
问题 In order to get results in a random order from a Sql query I generally sort by new Guids. I have done this before with Entity-Framework, however for some reason its not working now. For example (using the adventureworks2008r2 database) i run the following query in LinqPad: (from t in Employees orderby Guid.NewGuid() select new {t.Person.FirstName,t.Person.LastName,t.JobTitle}) This generates the following SQL: SELECT [t1].[FirstName], [t1].[LastName], [t0].[JobTitle] FROM [HumanResources].

How can I Dump() a Newtonsoft JObject in LinqPad?

↘锁芯ラ 提交于 2020-01-21 03:58:24
问题 In LinqPad, trying to call .Dump() on a Newtonsoft JSON.Net JObject yields an exception: RuntimeBinderException: 'Newtonsoft.Json.Linq.JObject' does not contain a definition for 'Dump'. This works for almost everything else in LinqPad. I'd like to figure out a method that will Dump out a Newtonsoft JObject , just like other objects, showing property names, values, etc. I've already figured out how to get it to dump the JSON string, but I'd like to see an object get output rather than just a

Is there a library that provides a formatted Dump( ) function like LinqPad? [duplicate]

淺唱寂寞╮ 提交于 2020-01-19 04:58:05
问题 This question already has answers here : How do I use the LINQPad Dump() extension method in Visual Studio? [closed] (4 answers) Closed 5 years ago . I work with a lot of Linq queries in my code, and I'm looking for a library that provides a formatted Dump() function similar to what LinqPad offers. LinqPad's Dump() extension method is really quite nice, because it handles nested collections very well. Ideally, it would print out pretty tables in plain text, but I'd be ok with spitting out

CancellationTokenSource.CancelAfter not working

安稳与你 提交于 2020-01-11 09:45:52
问题 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

Finding Matching Nodes in two XML files using linqpad and linq to xml is finding 0 results

我们两清 提交于 2020-01-06 08:23:48
问题 I have two XML files with the same schema/structure but with different data. I am trying to use Linqpad (Linq to XML) to find the differences between the two files. Here is my code... XElement FILE1 = XElement.Load (@"..\FILE1.XML"); XElement FILE2 = XElement.Load (@"..\FILE2.XML"); var orders = from file1 in FILE1.Descendants("Players").Elements("Player") select new { name=new { firstName=file1.Element("FirstName"), lastName=file1.Element("LastName") } }; var orders2 = from file2 in FILE2

Find dynamic words through patterns in LINQ

混江龙づ霸主 提交于 2020-01-05 08:35:14
问题 Here is how the html starts BUSINESS DOCUMENTATION <p>Some company</p> <p> <p>DEPARTMENT: Legal Process</p> <p>FUNCTION: Computer Department</p> <p>PROCESS: Process Server</p> <p>PROCEDURE: ABC Process Server</p> <p>OWNER: Some User</p> <p>REVISION DATE: 06/10/2013</p> <p> <p>OBJECTIVE: To ensure that the process server receive their invoices the following day.</p> <p> <p>WHEN TO PERFORM: Daily</p> <p> <p>WHO WILL PERFORM? Computer Team</p> <p> <p>TIME TO COMPLETE: 5 minutes</p> <p> <p

Issue creating DbContext connection with LINQPad using Entity Framework 6.0 code first

时间秒杀一切 提交于 2020-01-04 15:29:19
问题 I'm using LINQPad v4.51.03 and attempting to create a DbContext connection from a code-first implementation in Entity Framework 6.0 (6.1.1). public partial class MyEntities : DbContext { public MyEntities() : base("mydbname") { ... The connection string looks like: <add name="mydbname" connectionString="Data Source=<db>;initial catalog=<cat>;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.EntityClient" /> In the LINQPad 'Add