entity-framework

Sorting by foreign key values in GridView with Entity Framework?

When using GridView's built in Sorting with Entity Framework, I can display foreign key values. For example... <asp:boundfield HeaderText="Category" DataField="Category.Name" SortExpression="Category.Name" /> ...but when the header is clicked to sort the items in the grid, how can I sort my List list by Category.Name? I only have th...

DB/Entity Design: table related to any one of multiple tables

A Report can have multiple charts. The Chart table looks as follows: Chart -- Id, ChartId, ReportId, ... The ChartId above can map to the ChartId to either one of the following Chart Types: Line: ChartId, Thickness, YAxis, XAxis, Color, ... Pie: ChartId, Radius, Color, ... Bar: ChartId, Width, Color, Border, ... I am using SQL Se...

How to display Linq to Entity query result in ASP.NET MVC view

I have a Link 2 Entity query expression in my ASP.NET MVC app: Dim var = From c In context.Evaluation_Template _ From ae In context.Assigned_Evaluation _ Join ua In context.User_Assignment On ae.Assignment_ID Equals ua.Assignment_ID _ Select c.Evaluation_Name, ae.Due_Date, ua.Is_Started, ua.Is_Completed, u...

Entity Framework, WCF & updates

I have created an n-tier solution where I am retrieving related data from a WCF service, updating it within a Windows Forms application, and then returning the updated data via WCF to be persisted to the database. The Application, WCF Service and Database are all on different machines. The data being retrieved consists of an object and ...

Troubleshooting ADO.NET Entity Framework and 1:* Relationships

I'm trying to accomplish a simple task of creating a database with 2 tables with a 1:* relationship. In one table (Foos) I have Id ... ... In the other (Bars) I have Id FooId ... ... ... I created a Foreign Key Relationship from Bars to Foos with the Foriegn Key Table being Bars pointing to the FooId column, and the Primary Key ta...

Microsoft MVC

Hi, I am pretty close to be done with a website using the entity framework and standard asp.net+ajax, but now I am thinking if it would be smarter to start over and do it with microsoft mvc. Is MVC going to be THE new thing, and should I try to implement it? How does MVC perform on high traffic sites? ...

Entity Framework Identity column not working

I am fairly new to the Entity Framework and am in the process of building my first MVC application. I'm implementing a Create View for a simple Entity however, I am having problems with the (SQL Express 2005) Identity column primary key. As I understand it the Framework should handle the Identity column and let the SQL database generat...

How do I use entity framework with hierarchical data?

I'm working with a large hierarchical data set in sql server - modelled using the standard "EntityID, ParentID" kind of approach. There are about 25,000 nodes in the whole tree. I often need to access subtrees of the tree, and then access related data that hangs off the nodes of the subtree. I built a data access layer a few years ago b...

Instantiating a context in LINQ to Entities

I've seen two different manners that programmers approach when creating an entity context in their code. The first is like such, and you can find it all over the MSDN code examples: public void DoSomething() { using TaxableEducationEntities context = new TaxableEducationEntities()) { // business logic and whatever else ...

SQL and entity framework

Hi, I have an application where I move data from one table to another on the same database (some simple calculations are done). I use the entity framework to select the data from the first table and add it to the other table.I try to transfer appx. 100k rows and the problem is that it seems like it kills the connection to my database. Af...

Getting Identity Column of new record in Entity Framework?

Hi there, Can anyone help? I have been using the entity framework and its going well :-) But i have just added a new record using an entity class like so this._entities.AddToUsers(user); The AddTo is created automatically .. and users is my table... All great but how do i return the identity column? The sounds like just what i need ...

Entity Framework - Using Transactions or SaveChanges(false) and AcceptAllChanges()?

Hi there, I have been investigating transactions and it appears that they take call of them selves in EF as long as i pass false to savechanges.. SaveChanges(false) and if all goes well then AcceptAllChanges() Question is what is something goes bad, don't have to rollback? or as soon as the my method goes out of scope its ended? Wha...

ADO.Net Entity framework object navigation?

Hi! I'm using ADO.Net Entity Framework and C# to retreive the languages of a destination using this: var list = from dd in guiaContext.DestinationDetail where dd.id_destination == destinationID select dd; But when I access language in a foreach: foreach (DestinationDetail detail in list) languagesList.Add(detail.Language...

How do I set a field to DBNull in Entity Framework

How do you set a field to DBNull in Entity Framework? The fields are strongly typed so you cannot set it equal to DBNull.Value and I did not find any method to set a field to DBNull. It seems like this is a necessary thing to do, but after much Google research I found nothing about it. I am trying to set a datetime field in Entity Fra...

How to pass query results with FK relations(EF) to the View

Hi, I am not able to figure out this simple thing in ASP.NET MVC: I have two tables: Customer: CustomerID FirstName LastName AddressID AddressTemporaryID Address: AddressID Street City I have my relations(FK) set in DB and trying to use Entity Framework. My navigation properties(FK) are named Addr...

How to choose a data access method in ASP.NET MVC?

I've been programming in C# 2.0 WinForms for a while now. I'm starting to get into ASP.NET and the new MVC framework and the new features of C# 3.5. I've only read a little on LINQ to SQL but have made a few test apps to try it out. In my WinForms apps, I usually had some sort of data access layer, and wrote all the SQL myself. Of course...

Should Entity Framework Context be Put into Using Statement?

The Entity Framework context object implements a Dispose() method which "Releases the resources used by the object context". What does it do really? Could it be a bad thing to always put it into a using {} statement? I've seen it being used both with and without the using statement. I'm specifically going to use the EF context from with...

HowTo Bind Crystal Reports to Entity Framework ?

How can one bind Crystal Reports to Entity Framework Entities? I did find no workaround yet. (And I have not enough points yet to vote on existing questions) ...

Same table relationship in Entity Framework

Is it possible to have an association mapping a table to itself? e.g. Table: ConditionId ConditionName ... ... ParentConditionId where we can have many ParentConditionIds each mapping to the same ConditionId. I've tried a one to many mapping but I'm getting an error when there is no children. ...

Entity Framework: Saving a record with FK values and NOT looking up relationships

I've got a table "Expenses" that contains an FK value to an "ExpenseType" table. Right now, if I want to save a new expense, I first get the int value of the FK, do a lookup to the ExpenseType table, and assign the object to the expense object. For example: //create new expense var e = new Expense(); //lookup the associated expense typ...