linqpad

Assignment to struct array inside method does not work in C#?

折月煮酒 提交于 2019-12-25 05:59:37
问题 Here is the code snippet from my LinqPad: public class Elephant{ public int Size; public Elephant() { Size = 1; } } public struct Ant{ public int Size; } private T[] Transform2AnotherType<T>(Elephant[] elephantList) where T:new() { dynamic tArray = new T[elephantList.Length]; for (int i = 0; i < elephantList.Length; i++) { tArray[i] = new T(); tArray[i].Size = 100; //tArray[i].Dump(); } return tArray; } void Main() { var elephantList = new Elephant[2]; var elephant1 = new Elephant(); var

Unable to convert MySQL query to LINQ

拈花ヽ惹草 提交于 2019-12-25 03:07:30
问题 I have already watched this solution but still, my question is same. I am unable to convert my MySQL query to LINQ . I am using LinqPad for it. I have created a connection. Executed my query and got the result. But the lambda section is empty. SELECT * FROM ( SELECT @row := @row +1 AS rownum, zdjh,sjsj ,xhqd FROM ( SELECT @row :=0) r, `tj_xhqd` ORDER BY sjsj ) ranked WHERE rownum % 24= 0 AND zdjh = '002999001180' AND sjsj>='2018-02-24 08:38:11' I want to convert this to LINQ . The model name

How do you use linq to xml to find matching nodes in two different xml files

左心房为你撑大大i 提交于 2019-12-24 19:07:46
问题 I just asked another question here and the answer was spot on. But that addressed what was essentially a syntax problem. Now I need help with an actual resolution. This is the same code from the previou question (fixed up and with stuff added). 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 { clientID=ulm.Element("ClientID").Value, firstName

How can I see warnings in Linqpad?

孤人 提交于 2019-12-24 06:03:36
问题 When I create C# Programs in LinqPad, I would like to see the warnings from the compiler. It already shows error messages. How can I see the warnings? 回答1: LINQPAD is not a full blown IDE to support everything.. it's an ergonomic C#/VB scratchpad that instantly executes any C#/VB expression, statement block or program.. so simply this feature is not supported as of now. 来源: https://stackoverflow.com/questions/4951069/how-can-i-see-warnings-in-linqpad

How can I see warnings in Linqpad?

爷,独闯天下 提交于 2019-12-24 06:02:29
问题 When I create C# Programs in LinqPad, I would like to see the warnings from the compiler. It already shows error messages. How can I see the warnings? 回答1: LINQPAD is not a full blown IDE to support everything.. it's an ergonomic C#/VB scratchpad that instantly executes any C#/VB expression, statement block or program.. so simply this feature is not supported as of now. 来源: https://stackoverflow.com/questions/4951069/how-can-i-see-warnings-in-linqpad

How to implement Dump as the one provided by LinqPad? [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-24 04:42: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 . Given (new [] {"a", "b"}).Dump() , LinqPad provides some very useful print results. It seems that this extension method is a short hand for Console.WriteLine . Question > how to implement this dump for myself? 回答1: This thread might be of use to you. Is there a library that provides a formatted Dump( ) function like LinqPad? 回答2: With a lot of

LINQ - Different results with LINQ to SQL vs LINQPad

前提是你 提交于 2019-12-24 01:58:10
问题 I am executing the "same" query using LINQ to SQL and in LINQPad, however the result set comes out slightly differently. The code is var conn = new SqliteConnection ( "DbLinqProvider=Sqlite;" + "Data Source=/home/larsenma/database.golden" ); Models.Main db = new Models.Main (conn); var runSum = from rr in db.Runrecords group rr by rr.RunID into rg select new { LaneCount = rg.Count(), } LINQPad properly calculates the "LaneCount" while with LINQ to SQL I get 1s for each record. With LINQ to

'Invalid column name [ColumnName]' on a nested linq query

霸气de小男生 提交于 2019-12-23 12:46:45
问题 Last update After alot of testing, I realised that if i ran the same query over the same dataset (in this case a Northwind) table on SQL 2000 and SQL 2005, I get two different results. On SQL 2000, i get the error that's in the question. On SQL 2005, it succeeds. So I've concluded that the query generated by linqpad doesn't work on sql 2000. To reproduce this, run: OrderDetails .GroupBy(x=>x.ProductID) .Select(x=>new {product_id = x.Key, max_quantity = x.OrderByDescending(y=>y.UnitPrice)

Canonical Console.WriteLine in LinqPad

╄→尐↘猪︶ㄣ 提交于 2019-12-23 06:50:20
问题 Linqpad's souped-up Console.WriteLine is awesome. However, how can I do a standard Console.WriteLine of an object? 回答1: Debug.WriteLine will also do the trick. 回答2: Huh, obvious now - put in an explicit ToString Console.WriteLine(x.ToString()); 回答3: You can also add these methods to your "MyExtensions" file in the "My Queries" pane. This way you can use .DumpToString instead of .Dump. Maybe they should be renamed DumpDebug ... // Write custom extension methods here. They will be available to