entity-framework

Concat Two IQueryables with Anonymous Types?

别说谁变了你拦得住时间么 提交于 2020-01-12 15:29:43
问题 I've been wrestling with this a little while and it's starting to look like it may not be possible. I want to Concat() two IQueryable s and then execute the result as a single query. I tried something like this: var query = from x in ... select new { A = ... B = ... C = ... }; var query2 = from y in ... select new { A = ... B = ... C = ... }; var query3 = query.Concat(query2); However, the last line gives me the following error: 'System.Linq.IQueryable' does not contain a definition for

Performance: .Join vs .Contains - Linq to Entities

柔情痞子 提交于 2020-01-12 15:25:54
问题 I am using Linq to entities to query the database to get the list of int for further processing. I have two ways to get the list as below: First is: List<int> lstBizIds = new List<int>() { 1, 2, 3, 4, 5 }; List<int> lstProjectIds = context.Projects.Where(x => lstBizIds.Contains(x.businessId)).Select(x => x.projectId).ToList(); Second is: List<int> lstBizIds = new List<int>() { 1, 2, 3, 4, 5 }; List<int> lstProjectIds = context.Projects.Join(lstBizIds, p => p.businessId, u => u, (p, u) => p

How to stay DRY whilst using LINQ to Entities and helper methods?

一笑奈何 提交于 2020-01-12 15:19:10
问题 Lets say that I have a particular way of deciding whether some strings "match", like this: public bool stringsMatch(string searchFor, string searchIn) { if (string.IsNullOrEmpty(searchFor)) { return true; } return searchIn != null && (searchIn.Trim().ToLower().StartsWith(searchFor.Trim().ToLower()) || searchIn.Contains(" " + searchFor)); } I would like to pull matches out of a database using Linq To Entities and this helper. However, when I try this: IQueryable<Blah> blahs = query.Where(b =>

How to stay DRY whilst using LINQ to Entities and helper methods?

让人想犯罪 __ 提交于 2020-01-12 15:17:44
问题 Lets say that I have a particular way of deciding whether some strings "match", like this: public bool stringsMatch(string searchFor, string searchIn) { if (string.IsNullOrEmpty(searchFor)) { return true; } return searchIn != null && (searchIn.Trim().ToLower().StartsWith(searchFor.Trim().ToLower()) || searchIn.Contains(" " + searchFor)); } I would like to pull matches out of a database using Linq To Entities and this helper. However, when I try this: IQueryable<Blah> blahs = query.Where(b =>

Unit testing with Effort and SQL CE in parallel fails

好久不见. 提交于 2020-01-12 14:39:28
问题 I'm evaluating unit tests using EF6 in combination with http://effort.codeplex.com/ and SQL CE Server (Local DB file) http://www.codeproject.com/Articles/460175/Two-strategies-for-testing-Entity-Framework-Effort was a quite good reference but now I'm stuck. I have 2 test projects (one for Effort and the other for SQL CE). If I'm running both separately everthing's fine. Running both in a row with the ReSharper test runner the last test project always fails. Either System

Unit testing with Effort and SQL CE in parallel fails

二次信任 提交于 2020-01-12 14:36:30
问题 I'm evaluating unit tests using EF6 in combination with http://effort.codeplex.com/ and SQL CE Server (Local DB file) http://www.codeproject.com/Articles/460175/Two-strategies-for-testing-Entity-Framework-Effort was a quite good reference but now I'm stuck. I have 2 test projects (one for Effort and the other for SQL CE). If I'm running both separately everthing's fine. Running both in a row with the ReSharper test runner the last test project always fails. Either System

Unit testing with Effort and SQL CE in parallel fails

孤人 提交于 2020-01-12 14:36:06
问题 I'm evaluating unit tests using EF6 in combination with http://effort.codeplex.com/ and SQL CE Server (Local DB file) http://www.codeproject.com/Articles/460175/Two-strategies-for-testing-Entity-Framework-Effort was a quite good reference but now I'm stuck. I have 2 test projects (one for Effort and the other for SQL CE). If I'm running both separately everthing's fine. Running both in a row with the ReSharper test runner the last test project always fails. Either System

Unit testing with Effort and SQL CE in parallel fails

女生的网名这么多〃 提交于 2020-01-12 14:36:03
问题 I'm evaluating unit tests using EF6 in combination with http://effort.codeplex.com/ and SQL CE Server (Local DB file) http://www.codeproject.com/Articles/460175/Two-strategies-for-testing-Entity-Framework-Effort was a quite good reference but now I'm stuck. I have 2 test projects (one for Effort and the other for SQL CE). If I'm running both separately everthing's fine. Running both in a row with the ReSharper test runner the last test project always fails. Either System

Entity Framework Guid

白昼怎懂夜的黑 提交于 2020-01-12 14:27:07
问题 I'm trying to setup the Entity Framework with SQL Server 2008. I'm using Guids for the keys on my tables. Is there a way to set it up so the keys are automatically generated by the database? I tried setting "RowGuid" to true and also set the column's default value to be "(newid())". Either way the mapped class still needs me to give it a Guid on the C# side. Any ideas? 回答1: Not yet: 17.4.Can I use a server-generated guid as my entity key? Unfortunately, in v1 of the EF this is not supported.

EF 6 Code First Stored Procedure - Read Only

放肆的年华 提交于 2020-01-12 14:21:06
问题 I have searched a few posts, but have come up short. I am using EF6 code first trying to get results from a stored procedure that is already setup in a database. My application is simple, it takes data from two different servers, performs some business logic, and then shows the user. I can use the .edmx file fine, which maps the function in the xml file. When I use Power Tools to show myself the XML file I do not see the function import from my code below so I am either missing a setup or I