entity-framework

Subquery in Where Clause of LINQ statement

╄→гoц情女王★ 提交于 2021-01-01 09:57:13
问题 So I tried to follow this example to have a sub-query in the where clause of this LINQ query. var innerquery = from app in context.applications select new { app.app_id }; IEnumerable<postDatedCheque> _entityList = context.postDatedCheques .Where(e => innerquery.Contains(e.appSancAdvice.application.app_id)); The objective was to select those records from postDatedCheques that have app_id in applications table. But I am getting following erros inside the where clause: Delegate 'System.Func'

Union Two Linq Queries

你。 提交于 2020-12-31 14:56:25
问题 I have two LinqToSql queries that return result sets: var grResults = (from g in ctx.GeneralRequests join rt in ctx.RequestTypes on g.RequestTypeId equals rt.RequestTypeId join sub in ctx.Logins on g.SubmitterStaffId equals sub.LoginId join onb in ctx.Logins on g.OnBehalfOfStaffId equals onb.LoginId where sub.GadId == gadId select new { Status = "Submitted", RequestId = g.GeneralRequestId, Submitter = sub.UserName, OnBehalf = (onb == null ? string.Empty : onb.UserName), RequestType = (rt ==

JsonPatchDocument onto a complex Entity Framework tracked object

北战南征 提交于 2020-12-31 04:59:45
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

JsonPatchDocument onto a complex Entity Framework tracked object

北城以北 提交于 2020-12-31 04:55:49
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

JsonPatchDocument onto a complex Entity Framework tracked object

≯℡__Kan透↙ 提交于 2020-12-31 04:55:21
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

JsonPatchDocument onto a complex Entity Framework tracked object

梦想的初衷 提交于 2020-12-31 04:55:13
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

How do I call SQLitePCL.Batteries.Init().?

六月ゝ 毕业季﹏ 提交于 2020-12-30 04:52:23
问题 I am attempting to create an SQLite database for my application and have come across this error. System.Exception: 'You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().' I created a simple console app the run the exact same code for creation, with no issues. The code looks like this! using (var dataContext = new SampleDBContext()) { dataContext.Accounts.Add(new Account() { AccountName = name, AccountBalance =

How do I call SQLitePCL.Batteries.Init().?

不想你离开。 提交于 2020-12-30 04:51:30
问题 I am attempting to create an SQLite database for my application and have come across this error. System.Exception: 'You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().' I created a simple console app the run the exact same code for creation, with no issues. The code looks like this! using (var dataContext = new SampleDBContext()) { dataContext.Accounts.Add(new Account() { AccountName = name, AccountBalance =

How do I call SQLitePCL.Batteries.Init().?

牧云@^-^@ 提交于 2020-12-30 04:51:25
问题 I am attempting to create an SQLite database for my application and have come across this error. System.Exception: 'You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().' I created a simple console app the run the exact same code for creation, with no issues. The code looks like this! using (var dataContext = new SampleDBContext()) { dataContext.Accounts.Add(new Account() { AccountName = name, AccountBalance =

Drop database if model changes in EF Core without migrations

徘徊边缘 提交于 2020-12-29 06:19:24
问题 In previous version of entity framework, one could recreate the database if the model changes, using some of the classes DropDatabseIfModelChanges and other related classes. In EF7 or EF Core i don't know how to do that. Run the migrations some times give problems and in the beginning of the project i need to change the models constantly. 回答1: There's currently no easy way to implement DropDatabseIfModelChanges in EFCore. EF6 worked by storing a snapshot of your model in the _