linqpad

How to perform an ODATA expand in LinqPad

六月ゝ 毕业季﹏ 提交于 2019-12-04 23:17:19
问题 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

Different SQL produced from Where(l => l.Side == 'A') vs Where(l => l.Side.Equals('A')

风格不统一 提交于 2019-12-04 15:46:34
问题 I've been experimenting with queries in LinqPad. We have a table Lot with a column Side char(1) . When I write a linq to sql query Lots.Where(l => l.Side == 'A') , it produces the following SQL -- Region Parameters DECLARE @p0 Int = 65 -- EndRegion SELECT ..., [t0].[Side], ... FROM [Lot] AS [t0] WHERE UNICODE([t0].[Side]) = @p0 However, using Lots.Where(l => l.Side.Equals('A')) , it produces -- Region Parameters DECLARE @p0 Char(1) = 'A' -- EndRegion SELECT ..., [t0].[Side], ... FROM [Lot] AS

JToken is not a reference of JObject?

核能气质少年 提交于 2019-12-04 15:01:38
I have not yet noticed that James Newton King wrote or spoke about what JToken is . I have made the incorrect assumption that it somehow holds a reference to JObject . This is not the case as the these LINQPad statements demonstrate: var json = @" { ""item"": { ""foo"": ""4"", ""bar"": ""42"" } } "; var jO = JObject.Parse(json); var jToken = jO["item"]["foo"]; jToken = "5"; jO.ToString().Dump("jO"); jToken.Dump("jToken"); The output: jO { "item": { "foo": "4", "bar": "42" } } jToken 5 Should not jO["item"]["foo"] == 5 ? First, let's talk about what a JToken is. JToken is the abstract base

How to add a reference to an assembly in LINQPad to access custom types?

风格不统一 提交于 2019-12-04 14:57:34
问题 Is there a posibility to add a reference to an assembly in LINQPad? I have some types in my assembly and I would like to use them in my LINQPad queries. 回答1: Just press F4 . This will pop up the Add Reference dialog. 回答2: You can also use the menu option to access the popup window to add references. Notice the >> arrows in menu bar. Click on it. Go to Query menu. Find References and Properties . Click on it. Following is example image from LINQPad 5: 回答3: I had to do fn and F4 at the same

Can I have an incrementing count variable in LINQ?

霸气de小男生 提交于 2019-12-04 09:50:16
问题 I want to do something like this: from a in stuff let counter = 0 select new { count = counter++, a.Name }; But I get a error telling me that counter is read only. Is there a way to do something similar to this, without declaring a variable outside of the query? Basically, I just want to show a count/index column in LINQPad (which is awesome, BTW), which means I can't declare counter ahead of time. 回答1: Rather than using side-effects, use the overload of Select which takes an index: stuff

LINQPad - Connection String to my Oracle DB

吃可爱长大的小学妹 提交于 2019-12-04 09:44:28
问题 I just started using LINQPad and all works great when connecting to my SQL Server DB, but now I'm trying to set up a second connection to my Oracle DB and I'm getting stuck as to how to do it. I downloaded the IQ driver (v 2.0.8.0 - Latest) and when I go to add a new connection, I select Oracle as my DB Provider and don't know how to do the rest based upon my usual connection string looking as follows: Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = [IP Address])(PORT = [Port]))

LINQPad script directory?

爱⌒轻易说出口 提交于 2019-12-04 08:49:29
问题 Does anyone know how to get hold of the path to the directory where the LINQPad script file (.linq) resides? Or to the script itself for that matter. Note that I'm not talking about the location of the "My Queries" folder, the one shown inside LINQPad. I can save a .linq file anywhere on disk, and open it by double-clicking on it. For instance, if I save the file to C:\Temp\Test.linq , and execute the program, I'd like to have either C:\Temp or C:\Temp\Test.linq . Basically I'd like something

How can I get the connection string for an SQL Express database listed in LINQPad?

跟風遠走 提交于 2019-12-04 04:21:11
Is there an easy way to get the connection string of a database listed in the connection window of LINQPad (other than using the object explorer of Visual Studio)? Jay Walker Making sgmoore 's comment into an answer: try this.Connection.ConnectionString.Dump(); In LinqPad 5 if your Language dropdown is set to C# Program and you have a database selected in the Connection dropdown, then you can get your string using string c = LINQPad.Util.CurrentDataContext.Connection.ConnectionString; 来源: https://stackoverflow.com/questions/25360921/how-can-i-get-the-connection-string-for-an-sql-express

InvalidOperationException: No method 'Where' on type 'System.Linq.Queryable' is compatible with the supplied arguments

天涯浪子 提交于 2019-12-04 03:43:53
问题 (Code below has been updated and worked properly) There is dynamic OrderBy sample from LinqPad. What I want to do is just simply apply 'Where' rather than 'OrderBy' for this sample. Here is my code: IQueryable query = from p in Purchases //where p.Price > 100 select p; string propToWhere = "Price"; ParameterExpression purchaseParam = Expression.Parameter (typeof (Purchase), "p"); MemberExpression member = Expression.PropertyOrField (purchaseParam, propToWhere); Expression<Func<Purchase, bool>

Can I remove a namespace import from a linqpad query?

和自甴很熟 提交于 2019-12-04 03:24:53
问题 I am trying to run a linqpad query, but one of the default namespace imports has a type that is apparently shadowing the type I am trying to reference. System.Xml is one of the default imports in linqpad, but I rarely use it. Is it possible to remove that default namespace import, so I can use my own Formatting enum? 回答1: This isn't a direct answer to your immediate question, but you can can tell LINQPad which one you want Formatting to mean. In your query, press the F4 key and then under the