entity-framework

Entity Framework - How to update fields from a list of key-value pairs?

拥有回忆 提交于 2020-01-05 21:06:11
问题 Let's say the user modifies his profile record that contains fields such as FirstName, LastName, Email, etc. For each field that is modified, the change is stored as a key-value pair in a list of type: List<Tuple<string, object>> The key in this key-value pair represents the actual table column. While trying to update the record, here is one way to do it: foreach (Tuple<string, object> field in changeList) { if (field.Item1.equals("FirstName")) { user.FirstName = field.Item2; } if (field

Unable to install EntityFramework 6.1.3 in VS2015 web project

旧城冷巷雨未停 提交于 2020-01-05 17:58:11
问题 In my VS2015 WebApi project, I try to install NuGet package EntityFramework 6.1.3 using the following command from Package Manager. The command runs with success as the message below shows. But the package is still not installed and I get an error when I compile the project: PM> Install-Package EntityFramework Installing NuGet package EntityFramework.6.1.3. Successfully installed 'EntityFramework 6.1.3' to myWebProjectName The compile error : Error NU1001 The dependency EntityFramework >= 6.1

Unable to install EntityFramework 6.1.3 in VS2015 web project

爷,独闯天下 提交于 2020-01-05 17:57:57
问题 In my VS2015 WebApi project, I try to install NuGet package EntityFramework 6.1.3 using the following command from Package Manager. The command runs with success as the message below shows. But the package is still not installed and I get an error when I compile the project: PM> Install-Package EntityFramework Installing NuGet package EntityFramework.6.1.3. Successfully installed 'EntityFramework 6.1.3' to myWebProjectName The compile error : Error NU1001 The dependency EntityFramework >= 6.1

How to get a list of EntityObject's from an EF model

梦想与她 提交于 2020-01-05 17:38:46
问题 I need to be able to iterate of a list of EntityObjects that are in an EF model. For Example.. foreach (System.Data.Objects.DataClasses.EntityObject eObject in ????) { } From what I can see the model context has no such public enumerator. Anyone ever done this? 回答1: The problem here was i needed a dynamic way to iterate over the EntityObjects which are also consider types in the EDMX. I needed to list the Entity name and its properties. Thanks very much to Craig Stuntz for leading me down the

How to get a list of EntityObject's from an EF model

倾然丶 夕夏残阳落幕 提交于 2020-01-05 17:38:22
问题 I need to be able to iterate of a list of EntityObjects that are in an EF model. For Example.. foreach (System.Data.Objects.DataClasses.EntityObject eObject in ????) { } From what I can see the model context has no such public enumerator. Anyone ever done this? 回答1: The problem here was i needed a dynamic way to iterate over the EntityObjects which are also consider types in the EDMX. I needed to list the Entity name and its properties. Thanks very much to Craig Stuntz for leading me down the

can not retrieve data of navigation properties in EF 5, MVC 4

走远了吗. 提交于 2020-01-05 16:49:00
问题 I have the following PersonelInCourse entity: public partial class PersonnelInCourse { public int ID { get; set; } public string PersonnelID { get; set; } public string CourseID { get; set; } public int HoursInCourse { get; set; } public byte IsApproved { get; set; } public byte IsPassed { get; set; } public Nullable<int> RewardDetailID { get; set; } public string RejectReason { get; set; } public string FailReason { get; set; } public virtual Course Course { get; set; } public virtual

can not retrieve data of navigation properties in EF 5, MVC 4

感情迁移 提交于 2020-01-05 16:48:02
问题 I have the following PersonelInCourse entity: public partial class PersonnelInCourse { public int ID { get; set; } public string PersonnelID { get; set; } public string CourseID { get; set; } public int HoursInCourse { get; set; } public byte IsApproved { get; set; } public byte IsPassed { get; set; } public Nullable<int> RewardDetailID { get; set; } public string RejectReason { get; set; } public string FailReason { get; set; } public virtual Course Course { get; set; } public virtual

EF LINQ - Return entities that contain an entire collection

北城以北 提交于 2020-01-05 16:37:01
问题 I am trying to troubleshoot the following LINQ Query: public JsonResult SearchNodesByTags(string[] tags) { var nodes = _DbContext.Nodes. Where(n => n.Tags.All(t => tags.Contains(t.DisplayName))) .Select(n => new {n.NodeNativeId, n.NodeName, n.NodeClass.ClassName}) .ToList(); return Json(nodes); } The query is returning a single node that is not associated with a tag. What I want it to do, is return any nodes that have ALL the tags. 回答1: .Where(n => n.Tags.All(t => tags.Contains(t.DisplayName)

EF LINQ - Return entities that contain an entire collection

南笙酒味 提交于 2020-01-05 16:33:21
问题 I am trying to troubleshoot the following LINQ Query: public JsonResult SearchNodesByTags(string[] tags) { var nodes = _DbContext.Nodes. Where(n => n.Tags.All(t => tags.Contains(t.DisplayName))) .Select(n => new {n.NodeNativeId, n.NodeName, n.NodeClass.ClassName}) .ToList(); return Json(nodes); } The query is returning a single node that is not associated with a tag. What I want it to do, is return any nodes that have ALL the tags. 回答1: .Where(n => n.Tags.All(t => tags.Contains(t.DisplayName)

About c# partial class accesibility

丶灬走出姿态 提交于 2020-01-05 13:53:26
问题 I have a question about partial classes in c# In This picture, I have a domain model. I am have added reference this(DomainModelLib) to Client application and repoistory application. Repository application is using this domain model classes as "DbSet" and getting data from database. Realtions are created in model partial classes as you can see. I referenced Model to Client application. I wanna first partial(first red frame) of Product class can access in Client application but second part