entity-framework

Multiple Inheritance with Entity Framework with TPH

Further to this question: http://stackoverflow.com/questions/1877411/entity-framework-tph-with-multiple-abstract-inheritance and VS.2008 sp1 .net 3.5 c# I decided to add Organizations and a School. Organization(abstract) inherits from Party, and School(concrete) inherits from Organization. I get the error: Error 1 Error 3034: Pr...

Entity Framework 4, defining relationship

When defining a relationship in entity framework 4 in a 1-to-many relationship using POCO classes why does the relationship have to be defined at the child level. for example say we have an order that has many products. The relationship in the mapping file for the product would look like:- Relationship(e => e.Order) .Fro...

Best way to use entity framework in business layer and/or data layer?

I would like to use entity framework in my asp.net application. I am new to entity framework. I can use Linq to entities in any layer, but i would like to know best way where should i put Entity Framework? (DAL, BAL or direct use in Presentation). Any help would be appreciated. ...

VS2008 + MVC2 RC + L2S or VS10Beta2 + MVC2 Preview 2 + EFv4

I'm starting a new project which must have a working prototype within 10 days. The project should be cutting edge and I'd love to use latest tech, especially EFv4. But, also I like new MVC2 features like ForEdit and easier validation implementation (for Areas I don't care). MVC2 RC is out for VS2008 and works on VS10Beta 2 too, but "too...

In EntityFramework how do you reload entities in a Many to Many relationship?

Hi First off I'm using .Net 3.5 SP1. I have a few entities related as follows. An Engineer has many Appointments An Appointment has many Engineers A Timeslot has many Appointments I'm providing functionality in my data access layer to undo/discard changes made to entities. I'm doing this by calling... ObjectContext.Refresh(RefreshMod...

Can some one help me to conver it into LINQ i m using Entity Framework.

select ForumCategories.ID , ForumCategories.Title , ForumCategories.DateCreated, CO = ( select COUNT(*) from ForumSubCategories where ForumSubCategories.CategoryID_FK = ForumCategories.ID) from ForumCategories ...

Entity Framework: Mapped multiple Tables into one Entity -Insert problems

Hi all! Today I have an Entity Framework Question. I have two Tables: Projects and Projects_Rights Projects contains some Projects... Project_Rights contains access rights for each Identity (=User) for each Project. This Table is computed by triggers/functions. Mapping those table into one entity was no challenge: class Project {...

How to get the entity object from RowDataBound in a EntitydataSource bound gridview

I have a GridView that is bound to an Entity Framework object. I want to access the object in the RowDataBound event of the GridView. When I try to access the DataItem object i get an error stating Unable to cast object of type 'System.Data.Objects.MaterializedDataRecord' to type 'BBM.NailArtGallery.Model.Item'. Apparently the Materializ...

Can Anyone recommend a well design open source project with Entity Framework?

Can Anyone recommend a well design open source project with Entity Framework? I had some tastes about the Entity Framework 4, but I would love to know how people use this framework in some large projects. Many thanks. Daoming ...

Retrieve only base class from Entity Framework

If I have three classes in entity framework. class Base {} class Left : Base {} class Right : Base {} and I call DBContext.Bases.ToList(); This returns all instances of Base fully typed into their associated inherited types, as some people have noticed, the performance of EF on large inheritance structures is not great to say the l...

Entity Framework 4.0: Why Would One Use the Code Generated EntityObjects Over POCO Objects?

Aside from faster development time (Visual Studio 2010 beta 2 has no T4 templates for building POCO entity objects that I'm aware of), are there any advantages to using the traditional EntityObject entities that Entity Framework creates, by default? If Microsoft delivers a T4 template for building POCO objects, I'm trying to figure out w...

Patterns for handling a SQL deadlock in C#?

I'm writing an application in C# which accesses a SQL Server 2005 database. The application is quite database intensive, and even if I try to optimize all access, set up proper indexes and so on I expect that I will get deadlocks sooner or later. I know why database deadlocks occur, but I doubt I'll be able to release the software withou...

Entity Framework - Cannot convert lambda expression to type 'string' because it is not a delegate type

I am using Entity Framework in my C# based code. I am running into an unexpected weirdness and am looking for suggestions. Case 1, 2, 3, 4... Projects: RivWorks.dll RivWorks.Service.dll RivWorks.Alpha.dll Samples (all of these work): RivWorks.Alpha.dll: public static bool EndNegotitation(long ProductID) { var product = (from a ...

Entity Framework - Clear a Child Collection

I have run into an interesting problem with Entity Framework and based on the code I had to use to tackle it I suspect my solution is less than ideal. I have a 1-to-Many relationship between Table A and Table B where entities in TableB have a reference to TableA. I have a scenario where I want to simultaneously delete all children of a r...

How can I maintain deferred execution with EF while projecting into another type?

I'm using EF 4 and I need to find a way to maintain deferred execution and project into another type. This is my existing code: AppointmentRepository appointmentRepository = new AppointmentRepository(); var appointmentGridItems = from a in appointmentRepository.ListAppointments() select new AppointmentGridIte...

Issue adding an inherited object in Entity Framework.

I am working on a small project using Entity Framework. I have a Group entity and a MissionTrip:Group entity (and also a SmallGroup:Group entity but that shouldn't be necessary information). I am using Table-Per-type inheritance set up analogously to the inheritance in this blog post by Muhammed Mosa. I can't save a MissionTrip to the G...

C# - Entity Framework - The EntityContainer name must be unique. An EntityContainer with the name 'Entities' is already defined.

For a little background: I have a DLL project with the following structure: Rivworks.Model (project) \Negotiation (folder) Model.edmx (model from DB #1) \NegotiationAutos (folder) Model.edmx (model from DB #2) I have moved the connection strings from this project's app.config to the web.config file. They ...

Entity Frameworks - ToList() and 0 Records

When expecting a recordset (>=1 record) how do you check for that 0 record situation? For example: RivWorks.Model.FeedStoreReadOnly store = new RivWorks.Model.FeedStoreReadOnly(AppSettings.FeedAutosEntities_connString, AppSettings.FeedAutosEntities_metadata, AppSettings.FeedAutosEntities_providerName); RivWorks.Model.NegotiationAutos.E...

How to: A ListBox from two sources?

I am using EF with WPF. How should I create a ListBox that shows both Contacts and Persons? My question is rather how to retrieve it and create the CollcetionViewSource(s). I know I will have to use ItemTemplateSelector, that's less what I care, what I really care is the retrieval, but any tips on the representation will be welcommed as...

Entity Framework SQL Query Execution

Using the Entity Framework, when one executes a query on lets say 2000 records requiring a groupby and some other calculations, does the query get executed on the server and only the results sent over to the client or is it all sent over to the client and then executed? This using SQL Server. I'm looking into this, as I'm going to be s...