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

How can I dump the normal properties on an IEnumerable in Linqpad

房东的猫 提交于 2020-01-04 04:21:11
问题 If I have an object that among other things is an IEnumerable and I dump this object I get the enumerated values. Is there a way to get Linqpad to list the other properties: Se example below: Can I get Dump to include Hello and digits properties? void Main() { var t = new test(); var d = new Dictionary<string,string> {{"Hello","World"},{"Good by","Sky"}}; t.Dump(); d.Dump(); } // Define other methods and classes here public class test : IEnumerable { public string Hello { get { return "World"

Using linqpad as primary query tool

牧云@^-^@ 提交于 2020-01-03 08:32:16
问题 A member of my team recently moved to LinqPad as his primary query tool (still will use SQL Studio at times) for the simple purpose of forcing himself to make using LINQ more natural to use. I thought this was a pretty good idea and am considering asking the rest of my team to make this switch. Does anyone have any thoughts / ideas on taking this approach? Early questions I had... I feel being able to write good ANSI SQL is critical for a LOB developer. Since LINQ is a Microsoft thing, is the

Why am I getting DllNotFoundException when adding SQLite Nuget Package to LINQPad?

淺唱寂寞╮ 提交于 2020-01-01 09:38:41
问题 I have added the System.Data.SQLite.Core NuGet package to my LINQPad 5 Query (Premium) and then try to execute the following: new SQLiteConnection(":memory:").Dump(); But I get: DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) How can I tell LINQPad where to find the SQLite Native DLLs? Please note I do not want to use the IQ Driver. 回答1: This library is not referenced in the standard way, because it's