linqpad

Generated SQL with PredicateBuilder, LINQPad and operator ANY

南笙酒味 提交于 2019-12-01 09:22:49
问题 I previously asked a question about chaining conditions in Linq To Entities. Now I use LinqKit and everything works fine. I want to see the generated SQL and after reading this answer, I use LinqPad. This is my statement: var predProduct = PredicateBuilder.True<Product>(); var predColorLanguage = PredicateBuilder.True<ColorLanguage>(); predProduct = predProduct.And(p => p.IsComplete); predColorLanguage = predColorLanguage.And(c => c.IdColorEntity.Products.AsQueryable().Any(expr));

Linq query error

柔情痞子 提交于 2019-12-01 00:49:17
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. A very simple way to do it: var query = People .Expand("TitlesActedIn") .Where(p => p.Name == "George Lucas") .First() .TitlesActedIn.Select(t => t.ShortName); query.Dump(); Its important to note, that this will crash if

How can I use LinqPad's generated context in Visual Studio

折月煮酒 提交于 2019-11-30 22:05:53
This is a follow-on from this question really: Moving From LINQpad to a Proper Visual Studio Project? ..but I'm not able to get it to work properly. An answer to that question suggestions dumping the context assembly out as a dll but although I have done that, when I import it as a reference, it's not exactly clear to me how I would create an instance of that context, point it at a database and actually run a query against it, something like the following: var db = new ContextFromThatDLL(myconnectionstring); var query = from a in db.MYTABLE where a.ID == 1 select a; Extra information: I am

Cast string as Guid using LinqPad

风流意气都作罢 提交于 2019-11-30 18:02:37
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 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(); You currently have an assignment, but you want to use a comparison - use == instead of = : var ProductIds = from p in Products where

How can I use LinqPad's generated context in Visual Studio

喜夏-厌秋 提交于 2019-11-30 17:26:55
问题 This is a follow-on from this question really: Moving From LINQpad to a Proper Visual Studio Project? ..but I'm not able to get it to work properly. An answer to that question suggestions dumping the context assembly out as a dll but although I have done that, when I import it as a reference, it's not exactly clear to me how I would create an instance of that context, point it at a database and actually run a query against it, something like the following: var db = new ContextFromThatDLL

How can I Dump() a Newtonsoft JObject in LinqPad?

北战南征 提交于 2019-11-30 17:13:51
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 text string. For anyone who lands here wanting to get pretty LINQPad output from a JSON string,

How to generate the F# type signature similar to FSI in my own code?

纵饮孤独 提交于 2019-11-30 12:18:10
If one uses the F# Interactive Shell (FSI), the inferred expression type ( signature ) is printed to the console along with its value: val it : int * string * float = (42, "Hello F#", 42.0) How can I mimick the same behaviour in my own code, e.g. to get the inferred types as string for a F# expression? I don't need to dynamically evaluate any F# expressions, the expressions are known in compile time and are part of my (static) F# code. I need this feature to be able to mimick the FSI output in LINQPad for my F# demos. Stephen Swensen Using Unquote Unquote has a facility for getting the F#

Entity framework Include command - Left or inner join?

一世执手 提交于 2019-11-30 11:08:48
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 have a Cities table and Persons table and a person can have a NULL CityID . Why does entity Framework

Linq distinct not working correctly

末鹿安然 提交于 2019-11-29 15:18:45
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 you can see I'm trying to extract data from a text description in a log table using groups. The query

LINQ to Entities not returning expected result

不羁岁月 提交于 2019-11-29 15:12:41
I am using a view to return a complex search query. When I usin linq to query against EF it is returning the same row 3 times(the actual rowcount is correct). using LinqPad I have run the same linq against my ef entity and the actual database view. ReadmitPatientList .AsQueryable() .Where("PatientLastName.StartsWith(\"cooper\")") .OrderBy (rpl => rpl.PatientLastName) .Dump(); That is the linq I am using for both. linqpad shows the lambda as this: EF: ReadmitPatientList.MergeAs (AppendOnly) .Where ( => .PatientLastName.StartsWith ("cooper")) .OrderBy (rpl => rpl.PatientLastName) DB