entity-framework-4.1

Explicit loading of grandchild collections in EF 4.1

拟墨画扇 提交于 2019-12-20 11:22:32
问题 Given the following model ... public class Parent { public int Id { get; set; } public ICollection<Child> Children { get; set; } } public class Child { public int Id { get; set; } public ICollection<Grandchild> Grandchildren { get; set; } } public class Grandchild { public int Id { get; set; } } ... we can eager load with Include a Parent with all Children and Grandchildren in one step like so: context.Parents.Include(p => p.Children.Select(c => c.Grandchildren)) Is something similar possible

Linq for entities Framework 4.1 tutorials/ebooks links [closed]

假如想象 提交于 2019-12-20 10:57:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Is there any good LINQ tutorial for Entities Framework 4.1 Code First for medium to complex level? Please suggest books as well. 回答1: For Linq-to-entities you can check MSDN: Syntax examples Linq-to-entities Sources for EFv4.1 code first are: ADO.NET team blog Morteza Manavi's blog Julia Lerman's blog Stack

Entity Framework Code First Class with parent and children of same type as it's own class

Deadly 提交于 2019-12-20 10:47:33
问题 I have a class of Content which should be able to have a parentId for inheritance but also I want it to have a list of child content which is nothing to do with this inheritance tree. I basically wanted a link table as ChildContentRelationship with Id's for parentContent and childContent in it and the Content class would have a list of ChildContentRelationship. This has caused a lot of errors. Here's waht I sort of want to do public class Content { public int Id { get; set; } public int?

Entitity Framework 4.1 - Code First- Unit testing data access layer

回眸只為那壹抹淺笑 提交于 2019-12-20 06:37:38
问题 I'm a .NET developer and I'm writing tests for my data access layer. I have tests that use fake repository - I have achieved that by using Moq and Ninject. I'm getting my head around EntityFramework 4.1 Code First model and I'd like to create a prototype for CRUD routines. It's an MVC app, so my entities won't be tracked by a context. To me it feels wrong that I'm writing tests that will make changes to the database. I will then have to clear the database each time I want to run these tests.

What's the correct way to use ObjectResult with input parameters to StoredProcedure in Entity Framework? (Output mapped to Complex Type Property)

醉酒当歌 提交于 2019-12-20 06:19:48
问题 I have several listboxes which have a SelectedItem property I intend to use as input parameters to execute my stored procedure in Entity Framework. I now realize my only hope for easily returning entity objects as the result of my Stored Procedure is to map the Stored Procedure (or Function Import) to a complex type which matches the output. (Used Julie Lerman's post here to make this decision.) However, I need help using ObjectResult with EntityFramework to capture my listbox SelectedItem

How to read Custom Attributes using reflection set by Fluent API in EF 4.1

一个人想着一个人 提交于 2019-12-20 04:37:27
问题 I've managed to read custom attributes when I use data annotation. like following code. Object[] test = propertyInfo.GetCustomAttributes(typeof(KeyAttribute), true); But when I changed to use Fluent API. I couldn't read that attribute anymore. Any idea? 回答1: Fluent API does not set attributes. Fluent API and Attributes tell EF how to build the model. These are two different ways to achieve the same thing. That is to build the Model. Edit If you need to retrieve the metadata such as primary

Entity Framework code first aspnet_Users mapping / joins

青春壹個敷衍的年華 提交于 2019-12-20 04:24:09
问题 I was wondering with Entity Framework 4.1 code first how do you guys handle queries that involve an existing aspnet_Users table? Basically I have a requirement for a query that involves the aspnet_Users so that I can return the username: SELECT t.Prop1, u.Username FROM Table1 t INNER JOIN aspnet_User u ON t.UserId = u.UserId Where t.Prop2 = true Ideally in linq I would like: from t in context.Table1 join u in context.aspnet_Users on t.UserId equals u.UserId where t.Prop2 = true But I'm not

Entity Framework code first aspnet_Users mapping / joins

丶灬走出姿态 提交于 2019-12-20 04:24:05
问题 I was wondering with Entity Framework 4.1 code first how do you guys handle queries that involve an existing aspnet_Users table? Basically I have a requirement for a query that involves the aspnet_Users so that I can return the username: SELECT t.Prop1, u.Username FROM Table1 t INNER JOIN aspnet_User u ON t.UserId = u.UserId Where t.Prop2 = true Ideally in linq I would like: from t in context.Table1 join u in context.aspnet_Users on t.UserId equals u.UserId where t.Prop2 = true But I'm not

Sql Server CE 4 and EF 4.1 CF Win 64 bit deployment

大城市里の小女人 提交于 2019-12-20 04:19:21
问题 Hi I have a following problem. I've created a project in 32 bit operating system. There I have installed EF 4.1 and SQL CE 4 for 32 bit. I've created a test table and launched it. Everything works, i.e. there is a connection to db and CRUD operations happen. In the reference pane I've set the copy local property for binaries EntityFramework.dll , System.Data.SqlServerCe.dll and System.Data.SqlServerCe.Entity.dll to true. Then I copy pasted the project into machine with x64 OS. It gives me the

EF4 Unknown Column In Field List

眉间皱痕 提交于 2019-12-20 03:23:29
问题 So, I am kind of stumped. I have been using a generic repository, and it works perfect. It sits on top of Entity Framework 4.1. I have used the same line of code to get a set of data numerous times and had no issues before. However, this one table in my database seems to be throwing an exception and I cannot for the life of me figure out how to fix it. This is the table design in the MySQL database Completed ========= CompletedId OldStepId NewStepId Name Step ==== StepId Name Description This