entity-framework-plus

Entity Framework Plus - FutureValue() in a foreach loop

怎甘沉沦 提交于 2021-02-08 07:33:27
问题 Recently I started using EF+ on our project with great success however sometimes I run into an issue that I have a set of entities for which I need to run a separate query. So if I have a set of 20 customers I need to run 20 queries separately. I wonder if there is way how to avoid this using EF+ FutureValue() somehow in a foreach loop. See this sample code: foreach (var customer in customers) { customer.SomeValue = ctx.SomeDatabaseTable.Where(myCondition).FutureValue(); // this would run 20

Filtering On ThenInclude, with EntityFrameworkPlus IncludeFilter

▼魔方 西西 提交于 2020-06-09 05:29:05
问题 I am trying to filter three child levels down and find only child elements where PropertyMailingAddress.Status== True. How do I convert filter three levels down and conduct nested filtering with EntityFrameworkPlus IncludeFilter? What is the most efficient way? Class Structure is nested like this: Property PropertyParty Party PartyMailingAddress PropertyMailingAddress <--- Status should equal true (Any grandchild PropertyMailingAddress nodes with Status == False, should be removed from this

Database first approach with automatic CRUD logging

旧城冷巷雨未停 提交于 2019-12-12 15:33:11
问题 I have setup EF+ Audit as follows: public partial class FocusConnection : DbContext { static FocusConnection() { AuditManager.DefaultConfiguration.AutoSavePreAction = (context, audit) => // ADD "Where(x => x.AuditEntryID == 0)" to allow multiple SaveChanges with same Audit (context as FocusConnection).AuditEntries.AddRange(audit.Entries); } public override int SaveChanges() { var audit = new Audit(); audit.PreSaveChanges(this); var rowAffecteds = base.SaveChanges(); audit.PostSaveChanges();

Build expression from object

跟風遠走 提交于 2019-12-11 13:42:47
问题 I have the following object received from Angular client application in ASP.NET Core: public class ModelFromClient { public string name {get;set;} //Database field is Name public int qunatity {get;set;} //Database field is Quantity } And I have a EF Table class: [Table("MyTable")] public class MyRow { public int Id {get;set;} public string Name {get;set;} public int Qunatity {get;set;} } Now I need to create expression from ModelFromClient to Expression<Func<MyRow, MyRow>> and I need it with