entity-framework

Table-Valued Functions in Entity Framework?

Is it possible to call a Table-Valued Function (TVF) using Entity Framework? I have three TVFs defined in my database, and they do not show up in the Entity Framework's model, or in the "Update Model from Database" wizard. It's easily possible to do this in Linq-to-SQL, you simply drag the TVF onto the design surface, but in L2E it doe...

ADO.NET Entity Framework Custom SQL Expressions for Inserts/Updates/Deletes

Hi, In ScottGu's blog, he shows how to override methods of Linq to SQL classes so that modifications to data can be overriden in .NET side customly. http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx (Custom SQL Expressions for Inserts/Updates/Deletes part) Is there a way to acco...

Deleting data in Silverlight 3 with .NET RIA Data Services

We're trying to play around with RIA Services. I can't seem to figure out how to delete a record. Here's the code I'm trying to use. SomeDomainContext _SomeDomainContext = (SomeDomainContext)(productDataSource.DomainContext); Product luckyProduct = (Product)(TheDataGrid.SelectedItem); _SomeDomainContext.Products.Remove(l...

Alter SQLite DB structure when upgrading app

I would like to use the EntityFramework model to connect to an embedded SQLite database in my C# application. Everything works fine but as this is the first version of the software I expect future changes to have a cause changes to the structure of the database. I am concerned since I do not know when a user would upgrade from ver.1 to...

Pagnation with LINQ to entities

Hello I have a problem, I'm trying to use a helper-class for a MVC project. And I get error that I must use OrderBy somehow. this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize)) What to do? /M ...

How can I extend the Model in ASP.NET MVC and Entity Framework?

In my first ASP.NET MVC applications, the model was a simple O/R mapping between a table and the classes, managed by the Entity Framework. Now I would like to add some meat to this skeleton, and introduce business methods for the generated classes. What is the recommended approch to this in ASP.NET MVC (with Entity Framework)? My favori...

Saving a single entity instead of the entire context

I've run into a scenario where I essentially need to write the changes of a child entity of a one-to-many association to the database, but not save any changes made to the parent entity. The Entity Framework currently deals with database commits in the context scope (EntityContext.SaveChanges()), which makes sense for enforcing relation...

LINQ OrderBy Name ThenBy ChildrenCollection.Name

Is there any way in LINQ to do an OrderBy and then do a ThenBy with the ThenBy using the children of the parent object to do the secondary ordering? _repository.GetActiveDepartmentGroupsWithDepartments().OrderBy(c => c.DepartmentGroupName).ThenBy(c => c.Departments.OrderBy(d => d.DepartmentName)) In the above case, c.Departments is an...

Entity Framework connection metadata extraction

Hi, I am using the EntityFramework POCO adapter and since there are limitations to what microsoft gives access to with regards to the meta data, i am manually extracting the information i need out of the xml. The only problem is i want to get the ssdl, msl, csdl file names to load without having to directly check for the connection stri...

Using of Object Reference in Entity Framework

I want to create new object with the FK reference on the entity in onother table. It's just a simple create view but i don't know how to reference the Research entity with ID == id. public ActionResult Create(int id) { SurveyPaper surveyPaper = new SurveyPaper(); return View(surveyPaper); } [AcceptVerb...

how to get child table along with the parent in entity framework using entity sql like "select value tablename from tablename"

how to get child table along with the parent in entity framework using entity sql query for example var parentTable = "select value parentTable from parentTable as pt inner join childTable as ct on pt.key = ct.key"; doing this parentTable.childTable.count() returns 0. so how can i get the childTable loaded along with the parent table?...

Dynamic LINQ on a collection?

Hi there, I've a project which ask me to do such a BUG search engine but which is all dynamic. I mean I can have about 0 to 9 main "group" which have inside something like an infinite possibility of "where" with "OR" or "AND". First thing we think was to use Dynamic Linq which provide a good alternative to build dynamic query. All this ...

Ria Services Wizard with referenced Entity model problem?

Hey all. Imagine this structure. A solution with the following projects /Backend (RIA Silverlight client) /Backend.Web (RIA Silverlight Host / Service) /Core (Utility includes) /Frontend.Web (Front line MVC app) A entity framework model built in /Core should be able to be seen in Backend.Web IF there is a reference. Which there is....

Linq to Entities - Retrieve entity with "self-reference" from Stored Procedure

I can't quite figure this out. I have a table called Employee with and Id field. The table also contains a ManagerId field which has a foreign key pointing to the Employee's Id field. When I add the table as an entity to my entity data model it creates the new Employee entity with an EmployeeChildren collection element and an EmployeePar...

How to change the database - Schema used by Entity Framework (mysql database) ?

I use EntityFramework in a project to connect to a Mysql database. The provider is Devart Dot.connect. This application needs to connect to a database using connexion parameters given by the user at runtime. This includes of course the Mysql Database name. I used the EntityConnectionStringBuiler and EntityConnection classes to build-up...

How does Entity Framework work with recursive hierarchies? Include() seems not to work with it.

I have an Item. Item has a Category. Category has ID, Name, Parent and Children. Parent and Children are categories also. When I do a linq to entities query for a specific Item, it doesn't return the related Category, unless I use the Include("Category") method. But it doesn't bring the full category, with its parent and children. I co...

How can I automatically set a DateUpdated column using the Entity Framework?

I have a bunch of tables that have DateUpdated columns. How can I have those fields automatically set to DateTime.Now when the objects are persisted back to the data store when SaveChanges() is called. I don't need to do it across the board with one piece of code. I would be OK with adding event handlers in all of the partial classes,...

How do you use SaveChanges() method in Ado.net Entity Framework?

I set up an IDataContext and when i create a data class for an entity, i inherit it from IDataContext. IDataContext interface has 4 methods. IQueryable<T> GetAll(); T GetById(long id); void Add(T entity); void Delete(T entity); void Save(T entity); As you know Delete and Save methods have this structure; FooEntities db = new FooEnti...

Deleting a record returns from the dead after I submit changes using RIA Data Services

I have written a little program that deletes a record from the database using the RIA Data Services (Silverlight) and I am using a datagrid to view my entity. private void DeleteButton_Click(object sender, RoutedEventArgs e) { DataContext _PersonService = (DataContext)(personDataSource.DomainContext); person remo...

Dynamic Data Entities Web Application - "Object Reference Not Set..." runtime error in List.aspx markup

I have a Dynamic Data Entities Web Application with ADO.NET Entity Model generated from MS SQL 2005 database with 47 tables and about 30 relationships. All works well except one table, which gives Object reference not set to an instance of an object. runtime error when I'm trying to navigate to it from entry page tables' list - Defaul...