linqpad

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

Using C# 5 async feature in Linqpad

大憨熊 提交于 2020-01-01 08:40:48
问题 Is it possible to use C# 5 async features in Linqpad snippets? Does anyone know of any hack/beta which allows you to do it? 回答1: Installing the async CTP should be enough - async code should compile in LINQPad (although the Intellisense will show red squigglies). I'll look at dealing to the red squigglies in the next beta :) You will have to add a reference to asyncctplibrary.dll, as in VS. Update: the red squigglies and autocompletion has been dealt to in the latest beta. 来源: https:/

How does Visual Studio's debugger/interactive window dump the properties of COM Objects in .NET?

空扰寡人 提交于 2020-01-01 02:46:25
问题 In this related question, I noted that Visual Studio's debugger is able to enumerate the properties of System.__ComObject references, which is "a hidden type used when the wrapper type is ambiguous" -- e.g., the type of object you get when you obtain it from another COM object and don't instantiate it yourself: Additionally, if you simply write a COM object's identifier into the Immediate Window, its properties and values are similarly dumped: Note that this is separate from VS2010's "Dynamic

Linq query works with null but not int? in where clause

耗尽温柔 提交于 2019-12-30 08:51:33
问题 I have a linq query function like (simplified): public IList<Document> ListDocuments(int? parentID) { return ( from doc in dbContext.Documents where doc.ParentID == parentID select new Document { ID = doc.ID, ParentID = doc.ParentID, Name = doc.SomeOtherVar }).ToList(); } Now for some reason when I pass in null for the parentID (currently only have data with null parentIDs) and I get no results. I copy and paste this query into LinqPad and run the following: from doc in dbContext.Documents

Linq query works with null but not int? in where clause

半世苍凉 提交于 2019-12-30 08:51:16
问题 I have a linq query function like (simplified): public IList<Document> ListDocuments(int? parentID) { return ( from doc in dbContext.Documents where doc.ParentID == parentID select new Document { ID = doc.ID, ParentID = doc.ParentID, Name = doc.SomeOtherVar }).ToList(); } Now for some reason when I pass in null for the parentID (currently only have data with null parentIDs) and I get no results. I copy and paste this query into LinqPad and run the following: from doc in dbContext.Documents

Cast string as Guid using LinqPad

半腔热情 提交于 2019-12-30 05:57:32
问题 When I run following in the LinqPad var ProductIds = from p in Products where p.Id = "F1FE990C-4525-4BFE-9E2C-A7AFFF0DDA1F" select p; ProductIds.Dump(); it gives me Cannot implicitly convert type 'string' to 'System.Guid' I just don't know how to apply proper cast it to GUid I guess 回答1: Try using the Guid.Parse(string guid) static method. var ProductIds = from p in Products where p.Id == Guid.Parse("F1FE990C-4525-4BFE-9E2C-A7AFFF0DDA1F") select p; ProductIds.Dump(); 回答2: You currently have

LINQpad: Global function SubmitChanges not found

我只是一个虾纸丫 提交于 2019-12-25 16:39:49
问题 I've got a C#-Statement in LINQpad 4.0 like this: var x = (from y in MyTable where y.ID == 12345 select y).Single(); x.PropA = "abc"; SubmitChanges(); When i execute the Statements i get the error The name "SubmitChanges" is not available in the current context How can i fix the problem or update my data using linqpad? On my research i just found something about using a second datacontext, but it should work with the first context... 回答1: Most likely, you've not set a database (connection).

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

╄→尐↘猪︶ㄣ 提交于 2019-12-25 05:59:52
问题 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