entity-framework

LinQ to Entities: Lambda expressions

Hi! I want to translate this var db = new PracticeEntities(); var destinations = db.DestinationDetails. Where(dd => dd.Language.Lang == "en-US" ...

MVC Create Artist which includes Contact data

I am fairly new to the MVC Framework and have spent the last few days/nights working through the tutorials. I have a loosely coupled design with Services and Providers and am using the Entity Framework. I am using all the latest software, Visual Studio 2008, .Net 3.5 Framework, MVC, Entity Framework. I'm trying to create a view Artist/C...

What is best to use between Linq to SQL and the Entity Framework?

Well I've been reading a couple of posts on this here on Stackoverflow but I'm still not not sure about the direction to take. Basically I'm developing a product which I will maintain for the next 10 or more years so I want to decide now as to which framework to stick with. So I need expert advice as to which framework I should adopt t...

ADO.Net Entity Framework An entity object cannot be referenced by multiple instances of IEntityChangeTracker

Hi, I am trying to save my contact, which has references to ContactRelation (just the relationship of the contact, married, single, etc) and Country. But everytime I try to save my contact, which is validated I get the exception "ADO.Net Entity Framework An entity object cannot be referenced by multiple instances of IEntityChangeTracker...

Can I abstract Entity Framework away from my Entities?

I have a Foo entity in Entity Framework. But I'm making it inherit from IFoo so that my business logic only knows IFoo - thus abstracting Entity Framework away. The problem is that Foo has a collection of Bar entities. And this collection is of type EntityCollection<Bar> . If I put this collection in IFoo as it is, I make IFoo depende...

Using the repository pattern with Entity Framework (mvc storefront)

Hi, can anyone give a helping hand, I been watching the videos for the mvc storefront and have create my own website using these techniques i.e. DDD, Repository pattern but i wish to use Entity Framework. In the Interfaces it returns IQueryable but with the entity framework i should return ObjectQuery instead? - I will be using LINQ. ...

Entity Framework Generic Repository Error

I am trying to create a very generic generics repository for my Entity Framework repository that has the basic CRUD statements and uses an Interface. I have hit a brick wall head first and been knocked over. Here is my code, written in a console application, using a Entity Framework Model, with a table named Hurl. Simply trying to pul...

Is there a difference between an Entity and a object?

Hi, Is there a difference between the terms Entity and Object? ...

Stored procedure and Entity Framework

Hello, I have stored Procedure getSalesOrder() returning a row structure like this: Order (map with EF), customfield1 , customfield2 ,customfield3. How can i use EntityFramework to get the order, and custom Fields Values ? ...

Connection string for a L2E web app

We have a class library (ProjA) which has L2E object context. This will be used in an Website (ProjB) and WCF Service (ProjC). How do I specify the connection string in the website (ProjB) web.config so that it uses the resource files from the class library project (ProjA). connectionString="metadata=res://*/db.csdl|res://*/db.ssdl|res:...

Entity Framework Insert In Code

I have a simple Entity Framework. For simplicity's sake I will transform the entity names to Northwind Like. I have a IEnumerable Of Customer and Item Objects I am trying to Create Orders which of course is made up (simplistically) of an Item and A Customer. How can I go about creating and inserting these Orders? -Hcane ...

How to map many tables with same schema to one class

Is there a way in entity framework or linq to sql classes to map one class to many different tables with the same schema. For example if I have a database with thousands of tables for different stocks. All of the tables have the same columns. Is there a way I could have a base type class that could be used for mapping the data to an o...

Entity Framework: Re-finding objects recently added to context

I am using the entity framework and I'm having a problem with "re-finding" objects I just created... basically it goes like this: string theId = "someId"; private void Test() { using(MyEntities entities = new MyEntities()) { EntityObject o = new EntityObject(); o.Id = theId; entities.AddToEntityObject(o); CallSomeO...

How do can I attach a Entity Framework object that isn't from the database?

I have a complete separation of my Entity Framework objects and my POCO objects, I just translate them back and forth... i.e: // poco public class Author { public Guid Id { get; set; } public string UserName { get; set; } } and then I have an EF object "Authors" with the same properties.. So I have my business object var auth...

How do I add an object with the entity framework when it has a foreign key object that already exists

I have 2 tables: tblAuthors - id - username tblPosts - id - authorid So if I create a new Post var post = new Post { Id=Guid.NewId(), Author=new Author { UserName="username", Id="id in database } }; The author of the post is already in the database, but the post itself is not... So I want to do: entities.AddToPosts(obj); b...

How to force a 20 minute time-out for sessions?

I'm very confused when it comes to what actually decides the session time-out. The web app needs to allow for a 20 minute "idle time" before logging (or throwing) users out. I've tried different setting on both sessionState and Recycle worker processes in IIS. The time-out remains too short and, as far as my quit-n-dirty, primitive tes...

CompiledQuery vs. Plain Linq SQL Generation

So I was doing some profiling of different ways to hit my SQLServer database. I did vanilla TSQL, a CompiledQuery, and a noncompiled Linq statement. The performance went in that same order, as expected, but I noticed something curious when profiling the latter two. The SQL generated by the CompiledQuery was MUCH better than what was g...

Add linq-entities association in MVC controller

Hi, in this MVC tutorial it showed how to decouple Controller from database logic using Repository and a Service layer. However the example is for a very simple model of pure properties. What about associations? Say if Product model has an association to the Users table through Owner association. The controller calls the service or the ...

Entity Framework - Bind Combobox to Normalised Table Field

I am currently trying to bind an entity to a form however I want to have DataConfidenceLevel (see below) bound to a combobox with ConfidenceDescription as the display member. What is the correct way to populate the combobox? (I am currently using WPF but a Winforms answer is acceptable) Thanks ...

Entity framework memory usage

The entity framework appears to use excessive amounts of memory when inserting new objects into a database. for(int i = 0; i < numOwners; ++i) { var owner = Owner.CreateOwner(); db.AddToOwnerSet(owner); for(int j = 0; j < numChildren; ++j) { var child = Child.CreateChild(); owner.Childs.Add(child); ...