linqpad

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

霸气de小男生 提交于 2019-12-04 03:23:00
问题 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. 回答1: lprun from LinqPad has already arrived: http://www.linqpad.net/lprun.aspx 回答2: 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(); 回答3: The ability to run LINQPad scripts from the

Using C# 5 async feature in Linqpad

≯℡__Kan透↙ 提交于 2019-12-04 02:17:32
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? Joe Albahari 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://stackoverflow.com/questions/5893882/using-c-sharp-5-async-feature-in-linqpad

VB.NET linq group by with anonymous types not working as expected

吃可爱长大的小学妹 提交于 2019-12-04 00:12:47
问题 I was toying around with some of the linq samples that come with LINQPad. In the "C# 3.0 in a Nutshell" folder, under Chater 9 - Grouping, there is a sample query called "Grouping by Multiple Keys". It contains the following query: from n in new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }.AsQueryable() group n by new { FirstLetter = n[0], Length = n.Length } I added the string "Jon" to the end of the array to get an actual grouping, and came up with the following result: This was exactly what

Linq query error

不打扰是莪最后的温柔 提交于 2019-12-03 21:47:45
问题 I am using following Linq query: from p in People where p.Name == "George Lucas" select p.TitlesActedIn where TitlesActedIn is a list. People and TitlesActedIn are associted But I am getting error: InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.PropertyExpression' to type 'System.Data.Services.Client.ResourceExpression'. Please suggest solution. 回答1: A very simple way to do it: var query = People .Expand("TitlesActedIn") .Where(p => p.Name == "George Lucas")

How to get LINQPad to Dump() System.__ComObject references?

偶尔善良 提交于 2019-12-03 20:54:39
问题 I am playing around with using LINQPad to rapidly develop small ArcObjects (a COM-based library for ESRI's ArcGIS software) applications and have had some success in using it to Dump() the properties of COM objects that I initialize from .NET, but any COM objects that are obtained from an existing COM object are simply dumped as System.__ComObject references, which is not particularly useful: This help topic explains why this is happening, which I think I understand, but would like to know

Entity framework Include command - Left or inner join?

我只是一个虾纸丫 提交于 2019-12-03 19:44:17
问题 As I was investigating the difference between Include and Join I found that : If the DB does not include a Foreign Keys -it has no navigation props so it's better to use Join If It does have a navigation props - then use Include . ( it also save a db hit.) But one answer here caught my attention: Include is implemented as a join. Depending on the nullability of the included link it is an inner or left join. Question : How does the nullity affects the left / inner join ? In Sql server I can

Linq distinct not working correctly

馋奶兔 提交于 2019-12-03 18:12:17
问题 I'm having a strange problem with a linq query. I'm using LINQPad 4 to make some a query that uses regular expression using LinqToSQL as the LinqPad driver. Here's the query that I'm trying to make : (from match in from s in SystemErrors select Regex.Match(s.Description, "...") select new { FamilyCode = match.Groups["FamilyCode"].Value, ProductPrefix = match.Groups["ProductPrefix"].Value, BillingGroup = match.Groups["BillingGroup"].Value, Debtor = match.Groups["Debtor"].Value }).Distinct() As

How to use Visual Studio Team Services as a NuGet feed in LINQPad

≯℡__Kan透↙ 提交于 2019-12-03 15:23:01
I am using LINQPad 5 and VSTS (visual studio team services) I have a NuGet feed (v3) in VSTS and I would like to use packages from there(private) in LINQPad I have tried using the personal access token from VSTS as the NuGet password in LINQPad I have tried putting the VSTS credential provider for nuget in AppData\Local\NuGet\CredentialProviders I have tried putting the VSTS credential provider for nuget in AppData\Local\LINQPad\NuGet\CredentialProviders I have tried using my VSTS username and password as the nuget credentials How is this done? Is there a bug in LINQPad? Is this not supported

invalid cast exception on int to double

我们两清 提交于 2019-12-03 14:48:45
问题 Maybe I'm crazy, but I thought this was a valid cast: (new int[]{1,2,3,4,5}).Cast<double>() Why is LinqPad throwing a InvalidCastException: Specified cast is not valid. ? 回答1: C# allows a conversion from int directly to double , but not from int to object to double . int i = 1; object o = i; double d1 = (double)i; // okay double d2 = (double)o; // error The Enumerable.Cast extension method behaves like the latter. It does not convert values to a different type, it asserts that values are

How to perform an ODATA expand in LinqPad

[亡魂溺海] 提交于 2019-12-03 14:16:42
I'm using LINQPad to connect to the ODATA services on a local CRM organization and I don't know how to perform "joins" or to traverse relationships using LINQPad. Here is my URL OrganizationData.svc/New_locationSet?$select=new_state_new_location/new_Region$expand=new_state_new_location which works just fine in the browser. Here is what I'm doing in LINQPad: from l in new_locationSet from s in l.new_state_new_location select s.new_Region but I'm getting an error: An expression of type 'LINQPad.User.New_state' is not allowed in a subsequent from clause in a query expression with source type