entity-framework

Composing Linq to Entity Query from multiple parameters

I'm currently building a detailed search and I am trying to figure out how to compose my Linq query to my Entity. basically I have users that can select 1* items in a list control. the part I can't wrap my head around is the following: how can I dynamically build a Where AND( field is equal to this OR field is equal to this OR...) cla...

entity-framework a table without a unique key

There is a table in a database that i can't change i'm trying to use with Entity Framework. For sake of argument, there is no unique key possible, not even all the columns, all the columns are of type nvarchar(x), and i can't change the database to include a rownumber type column. Is there any way to get this table into Entity Framework...

Using Same Stored Procedure for Both Insert and Update in Entity Framework

I have a stored procedure that does both the insert and the update in one fell swoop (if the id == 0 then it's an insert, otherwise, update). I'd love to use this for both the insert and the update methods in Entity Framework, but this isn't looking feasible. Am I correct that I'll have to split the methods into two different stored proc...

Entity Framework: "The member in the conceptual model is not present in the OSpace"

I'm using RIA Services July CTP in a Silverlight app and when I change the name of a navigation property I get the following error: Error 119 The Member 'TestUsers' in the conceptual model type 'MyModel.UserGroup' is not present in the OSpace type 'MyApp.Web.UserGroup'. Is there an extra step when changing the name to a navigation p...

Is it good practice to have a table referenced by two different entities?

I am building a application with these patterns: Silverlight, RIA, EF, Prism, SL Unit Testing. This project will have lots of entities and lots of modules referencing those entities. Each entity is in its own RIA Service Library along with the RIA domain service and associated metadata. I am running into problems when I reference a ce...

sequence contains more than one element

Hi everyone, I receive the following error "sequence contains more than one element" when trying to populate my promotion table object. I know i recieve this error becuase my query returns multiple values as it should. Can anyone point me in the right direction as to how to delete multiple records besides looping(if possible with EF). ...

Linq to Entities and Xml Fields

Hi to all. I have this scenario: A SQL Server table myTable with field1, xmlField (nvarchar(50) and xml sql server data type) Linq to entities Now I'd like to get a query like this: SELECT Field1, XmlField FROM MyTable WHERE CAST(XmlField AS nvarchar(4000)) = '<myXml />' Obviously this is a correct query in SQL Server but I can't...

Entity Framework: Can you cascade deletes?

Hi there, I have an entity who's primary key is a foreign key in other tables in the database In order to delete a record in this entity I need to first delete all the foreign keys records or the delete will not work At the moment i have to select all the foeign key records manually and delete them which is a bit of a pain Is there a...

Ado.net entity data model doesn't exist

I've intalled vs2008 ts on my windows 7 x64 pc, but when I tried to add ado.net entity data model there is no template for it. All the MSDN tutorials say that vs2008 has it. ...

How do I update an Entity Reference using a SelectList in edit form? (asp.net mvc)

Hi There, Just trying to figure out how do achieve the following: I have an edit form, and a simple viewmodel for said form. The viewmodel contains an entity and then a few SelectLists for dropdowns. The problem is this: The entity in question has a related entity (which is called room). I want the user to be able to select a differe...

How do I Unit Test a function that inserts a record into a RIA Services DB?

Hi, This is a sample function that works with an entity, saves it to a db and then causes problems because we can't write a Unit Test for it. Check it out: // this class exists in a Silverlight Class Library public class EmployeeSaver { .... public void Go() { Employee e = new Employee(); e.Name="Jeremiah"...

Entity framework with "Group By" and/or "Order by"

Hi there, Say we've got a project that allows user to download things. On the main page, I want to show the Most downloaded files ordered by the number of download! All that using EF. How can i do this !! I've tried many things with Group By (Its a nightmare when you've got a lot of informations in an object). And i still dunno how to d...

Where "Ado.net entity frame work" files in 3 Layer Architecture ?

If I use ADO.NET Entity Framework in our project and we depend on 3-layer architecture pattern that we have ( presentation layer - business layer - data access layer ) a project for each layer So when I make an entity model file where can I put it in the DAL or BL? If I put it in the DAL and from Presentation layer want to access a do...

ObjectQuery<T> without Entity Framework

How to use ObjectContext and ObjectQuery<T> with my own classes and objects? I.e. I don't want to use them with Entity Framework. How can I do this? ...

Binding WPF ComboBox to entity.

Ok, Ive searched the heck out of the Interwebs and can't seem to find this right. I have a ComboBox that is bound to a CollectionViewSource of EntityFramework entities. The display is a template that shows the first/last name. The problem is, when an item is selected, the Display of the combobox == the object.ToString() (i.e. MyCompan...

Low-level SQL optimisation with Entity Framework

In the past when working with databases I've found it necessary to do low-level tweaks to the query, for example providing hints to the optimiser that it should use a particular index or join order. We are currently considering rewriting our data layer using Entity Framework; is it the case that using EF prevents this sort of low-level o...

How closely aligned is the Repository patten with either Unit of Work or ActiveRecord

Although I'm not doing full blown DDD, I find the repository pattern appealing and I do try to segment the repositories along aggregate-root boundaries. I'm implementing repositories on top of the Entity Framework, and here the ObjectContext allows for a unit-of-work style as it tracks changes to the entities and will generate the appro...

Visual Studio Model Won't Show SOME New Tables

I added some tables to my DB, and refreshing the model didn't work. So I deleted my .edmx file completely. I then recreated the model according to my updated DB, but the same tables were still missing. I'm not really sure why, but for some reason it won't load certain tables into the model. I looked at the XML .edmx and the tables ar...

Entity Framework ObjectContext -> raw SQL calls to native DBMS

I have an app using the ADO.NET entity framework (the VS2008 version, not the newer, cooler one) and I need to be able to make a call down to the underlying DBMS (it's postgres) in order to call some SQL that Entity Framework doesn't support. Is there a way to go from an Entity Framework ObjectContext to something that will let me exec...

When IQueryable is created from a linq query why is it not a "new" variable?

I am using the Entity Framework and have got a loop that looks at a set of People and using a foreach loop creates a query for the address of each person. As each address query is created it is added to the node of a treeview where it can be later used (to populate children nodes): IQueryable<Person> pQuery = (IQueryable<Person>)myCont...