linq-to-sql

Forcing Entity Framework to not generate NCLOB's when building Linq-to-Sql Code (Model First)

不羁的心 提交于 2021-02-19 00:36:01
问题 I have a class with a nullable int property that that for filtering reasons, I need to convert to a string to do some comparisons. I have EF 6.1.2 installed, so using a .ToString() will work for that. queryableData = queryableData.Where(a => a.PropName.HasValue && a.PropName.Value.ToString().Contains("8675309")); When examining the actual SQL being executed, the number is being CAST into an NCLOB type, which is resulting in the following error: ORA-00932: inconsistent datatypes: expected

Forcing Entity Framework to not generate NCLOB's when building Linq-to-Sql Code (Model First)

南楼画角 提交于 2021-02-19 00:34:36
问题 I have a class with a nullable int property that that for filtering reasons, I need to convert to a string to do some comparisons. I have EF 6.1.2 installed, so using a .ToString() will work for that. queryableData = queryableData.Where(a => a.PropName.HasValue && a.PropName.Value.ToString().Contains("8675309")); When examining the actual SQL being executed, the number is being CAST into an NCLOB type, which is resulting in the following error: ORA-00932: inconsistent datatypes: expected

Forcing Entity Framework to not generate NCLOB's when building Linq-to-Sql Code (Model First)

 ̄綄美尐妖づ 提交于 2021-02-19 00:34:11
问题 I have a class with a nullable int property that that for filtering reasons, I need to convert to a string to do some comparisons. I have EF 6.1.2 installed, so using a .ToString() will work for that. queryableData = queryableData.Where(a => a.PropName.HasValue && a.PropName.Value.ToString().Contains("8675309")); When examining the actual SQL being executed, the number is being CAST into an NCLOB type, which is resulting in the following error: ORA-00932: inconsistent datatypes: expected

Null ref when calling .ToList() within a Select function

拟墨画扇 提交于 2021-02-17 05:18:50
问题 in my .NET Core 3.1 application, I am getting a null reference exception when I include .ToList() on the following emailAddress =... line: var customersTask = eshop.TieredCustomer .Where(customer => customer != null) .Where(customer => customer.SendPriceListAutomatically.HasValue && customer.SendPriceListAutomatically.Value && customer.DistributionList.HasValue && !string.IsNullOrWhiteSpace(customer.Emails)) .Select(customer => new Customer { distributionList = customer.DistributionList.Value

LINQ contains one match from array of strings

北慕城南 提交于 2021-02-16 16:01:48
问题 Having trouble getting this to work: /// <summary> /// Retrieve search suggestions from previous searches /// </summary> public static string[] getSearchSuggestions(int SectionID, string Query) { string[] Suggestions; string[] Words = Query.Split(' '); using (MainContext db = new MainContext()) { Suggestions = (from c in db.tblSearches where c.SectionID == SectionID && Words.Any(w => c.Term.Contains(w)) select c.Term).ToArray(); } return Suggestions; } I get: System.NotSupportedException:

LINQ contains one match from array of strings

核能气质少年 提交于 2021-02-16 16:01:41
问题 Having trouble getting this to work: /// <summary> /// Retrieve search suggestions from previous searches /// </summary> public static string[] getSearchSuggestions(int SectionID, string Query) { string[] Suggestions; string[] Words = Query.Split(' '); using (MainContext db = new MainContext()) { Suggestions = (from c in db.tblSearches where c.SectionID == SectionID && Words.Any(w => c.Term.Contains(w)) select c.Term).ToArray(); } return Suggestions; } I get: System.NotSupportedException:

How to solve MVC 5 Update and Delete Error

前提是你 提交于 2021-02-11 14:16:01
问题 I have built MVC 5 Web application in .net 4.7.2. It runs fine in my local machine. Update and Delete commands were failing, which I have now sorted out thanks to this post: DELETE/PUT verbs result in 404 Not Found in WebAPI, only when running locally, I added this line to the web.config and all the CRUD now works: <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0 However,

How to search a varchar field, using LINQ, to build a list of recommendations

為{幸葍}努か 提交于 2021-02-10 20:24:13
问题 I am trying to construct a LINQ query, with expression trees, to do the following: I have a field in my ItemCode table called Labels, an example of the data contained in this field is "lamps lighting chandelier". I want to allow the user to type in some text, i.e. "Red Lamp", and be able to search the Labels field, of the ItemCode, table where the text contains "Red" or "Lamp". I am trying to recommend selections to the user, and this, while basic, is a good first step ... just need some help

SingleOrDefault() throws an exception on more than one element

☆樱花仙子☆ 提交于 2021-02-06 08:47:18
问题 I'm getting an exception whenever I fetch like this Feature f = o.Features.SingleOrDefault(e => e.LinkName == PageLink); because this can return one or more than one element. What is the alternative approach that I can use to solve this issue? 回答1: Single and SingleOrDefault are designed to throw if more that one match exists in the sequence. A consequence of this is that the entire sequence must be iterated prior to completion. It does not sound like this is what you want. Try FirstOrDefault

SingleOrDefault() throws an exception on more than one element

会有一股神秘感。 提交于 2021-02-06 08:46:00
问题 I'm getting an exception whenever I fetch like this Feature f = o.Features.SingleOrDefault(e => e.LinkName == PageLink); because this can return one or more than one element. What is the alternative approach that I can use to solve this issue? 回答1: Single and SingleOrDefault are designed to throw if more that one match exists in the sequence. A consequence of this is that the entire sequence must be iterated prior to completion. It does not sound like this is what you want. Try FirstOrDefault