entity-framework

EF EDM and ObjectQuery include / join

Hi I have these 2 entties in my edm: Parnter members: int id, string firstname, string lastname, Partner_Address partneradress Partner_Address members: int id, int partnerid, date validfrom If i use create my query like this: ObjectQuery.include("Partner_Address") i get a Partner entity and could access Partner_Adress properties (eg...

Inserting multiple rows into a table using Entity Framework

Hello all. I’m having fun with EF and have come unstuck. Originally I used the following bit of code using standard linq that essentially enters some data into a table. ManagePreferencesDataContext manpref = new ManagePreferencesDataContext(); tblManagePreference prefMemberID = new tblManagePreference(); ...

Entity Framework getting attribute/value pairs.

I'm working with an existing database, utilizing the Entity Framework for dynamic query builder. This is a key factor here. I don't know what types of objects I'll be working with until runtime, as the user is allowed to select which objects/properties they want with the query builder... So I'm using ObjectQuery<EntityObject>. Everythin...

Entity framework calling a FOR XML stored procedure truncates at 2033 characters

I have a stored procedure which uses a FOR XML statement at the end of it, and returns me some XML. I am using .NET 4 and the Entity Framework and when I do a function import of this stored procedure and try to call it through the Entity Framework it truncates the return at 2033 characters. I swapped the Entity Framework for a traditi...

Usage of WCF RIA Services without the Entity Framework

Can WCF RIA Services be used without the Entity Framework (for example, if the datasource is no classical database) ...

Lazy loading, Deferred Loading and Eager Loading in Entity framework

What are the differences between these 3 types of loading? Can someone explain with an example? Different resources online use different definitions causing more confusion than necessary. ...

to learn entity framework, how do i use it in a pet project?

hi all, i want to learn entity framework. i started with some EF tutorials and i also know little about linq to sql. i want to learn through a pet project. project should be in three layers. web forms (prez), data layer(c# lib), bussiness layer(c# lib). Project can be any, any functionality. just want to learn how to use EF in diff. la...

Linq Entity Framework -- can I use a recursive method?

Following on from the excellent answer to my previous question: http://stackoverflow.com/questions/3220155/linq-entity-framework-generic-filter-method I am now trying to understand how I can apply something like recursion to my solution. To recap, instead of multiple similar declarations of this method: protected IQueryable<Database....

How to use TextBoxFor to update the many side of a relationship

Suppose I have passed in a viewmodel with a PERSON record with multiple addresses I'm looking to write a view something like this (simplified) <% foreach (var addr in Model.PERSON.ADDRESSES) { %> <li> <%: Html.TextBoxFor(m => addr.Add1)%> </li> <% } %> Which appears to display as expected, however, each generated Text...

How can I set custom property of an Entity type in LINQ to Entities query and still return a IQueryable<T> ?

Hi, I have a EF4 model where I have Product entity that have one-to-many relation with Task entity (ChildTasks). I have to get some Projects from db based on some user criteria. The Project has one custom property (not associated with any column) named EstimatedProgress where I have to store additional information about Project - compute...

Error: The key-value pairs that define an EntityKey cannot be null or empty. Parameter name: record

I'm trying to update a record using the Entity model (3.5) when I get this error. I have no such parameter named "record". In walking through the code, a single entity is found, The four Entity keys are filled correctly("EntitySet=WOTimeRecording;WorkOrderNbr=69229;UserQID=Qlab64;WeekIdentifier=2010-Week14;TimeIdentifier=5") , and the ...

Best Practice for retrieving data using Entity Framework 4.0

Hi, I'm trying to understand some fundamental best practices using Entity Framework. My EDM design has Group and User entities which the Group may contain users and other groups. The question is: What is the best way to retrieve the users from a group? For getting the groups its easy, just creating the context object and creating a ...

Filtering derived classes in Entity set by OfType and getting exception.

Hello everybody I am trying to filter derived classes in my entities but i am getting exception. var filtered = db.PersonSet.OfType<Person>(). Where(person =>person.GetType()==typeof(Person)) I am getting below exception if i try to loop filtered collection by foreach. "LINQ to Entities does not recognize the method '...

How to partially load entity framework POCO

I have an EF 4.0 model that has a parent child relationship (say order and orderdetails) order { [primative] orderid, ordername, ordershipping [navigation] orderdetails } orderdetail { orderdetailid, orderpartid, orderquantity, orderpartname } My question is how do i load orders with orderdetails where the ...

Entity Framework: How to use entities as in-memory business objects

Hi, I'm sure most people who use the entity framework sometimes need an entity only for some business operations without it actually ever getting persisted to the database. For example, an online shop checkout wizard where you want to fill the customer and address info, but only persist it once the customer is at the end of the wizard a...

Should I pivot/crosstab db data on the server or client?

Hi, I have a Silverlight 3 app using WCF RIA Services and Entity Framework for the data-layer. I need to pivot some data and was wondering what the best practice is: Should the service return pivoted data, or should it just return a standard entity set and the client do the pivoting? Bearing in mind that the data needs to be editable s...

Entity Framework SaveChanges() not working?

I use entity framework with Visual Studio 2008, sure it was SP1 both .NET Framework and VS itself. My application is develop in n-tier environment. First step I convert data from context to collection and serialize to user. HRMSDBContext context = new HRMSDBContext(); List<InHouseTrainingHead> heads = context.InHouseTrainingHead.ToList...

Unable to access EntityCollection on silverlight client

Hi! I have created a silverlight application, using the silverlight business application template. I added a ADO.NET entity data model, and created it from scratch in the designer. I then generated a database from the model. The model has a "project" entity and a "client" entity with a many-to-many relationship. Then, I added a doma...

ADO.NET Ef4- How can i map a entity to stored procedure without mapping to table.

We are using ado.net entity framework 4.0 for our database layer and I am a newbie to ado.net entity framework. I have created entity via adding a entity in entity framework. I want to map that entity with stored procedure only not table of the database. Stored procedure will return same column as entity. How it is possible and how i can...

Dynamic query with Linq To Entities

I've got an EDM with two tables Product and ProductCategory with a many-to-many relationship between both. What I'm currently trying to do is to build a dynamic query to select the products related to the categories the user has selected through the UI. In short I should build a query like the following but based one or more categories...