entity-framework

Entity framework 3.5sp1 delete all in associated table?

Hello What is the equivalent to: DELETE * from ProductsCategories WHERE ProductID = 78 using entity framework 3.5sp1? Need to delete all categories that belongs to a product. /M ...

Exception deleting using Entity Framework (C#)

I have a problem with some simple code, I'm refactoring some existing code from LINQ to SQL to the Entity Framework. I'm testing my saves and deletes, and the delete is really bugging me: [TestMethod] public void TestSaveDelete() { ObjectFactory.Initialize(x => { x.For<IArticleCommentRepository>().Use<ArticleCommentRepos...

Optional columns in Entity Framework

Hi, Recently I started porting ADO.net app to Entity Framework. There are some optional columns in my table. With the ADO.net, I just check for existence of the column and get the value if it is there. if (MyTable.Columns.Contains("PerformPreCheck") && DBNull.Value != MyRow[MyTable.Columns["PerformPreCheck"]]) { m_bPerform...

How can I databind to an asp.net treeview using linq to entities?

I have seen other similar questions dealing with WPF Almost exactly the same but I can;t figure this out in ASP.net. I have a Pages table with a parentpage foreign key and want to databind them to a treeview. In the past I have created a hierarchicaldataset from a dataset but would like to stay within the entities framework if I can. ...

Problem deleting records using entity framework 4 self tracking entities

I have a Silverlight application that I use the Beta2 T4 Self tracking entities for. Inserting and updating records seems to be working but I haven't been able to remove items. My primary entity is called Contract. It has a navigation property to a collection of Contract2Service entities. When I retrieve a Contract object I can do this...

WPF, Entity framefork and validating models

Hello, I'm buidling an WPF application using the examples given in the link below as a basis: http://www.robbagby.com/silverlight/patterns-based-silverlight-development-part-ii-repository-and-validation/ In the example given, the uses the OnValidating partial method to invoke validation and if nessesary, throw an exception when someth...

linq to entity - include with lambda expression

I have a lite problem i don't really know how to fix. In my example below i would like to select a list of ProductCategories with ProductItems that are active. public IEnumerable<ProductCategory> ListProductCategories() { return _entities.ProductCategorySet.Include("ProductItems").Where(x => x.ProductItems.Active == ...

ADO.NET Entity Framework with OLE DB Access Data Source

Has anyone found a way to make the ADO.NET Entity Framework work with OLE DB or ODBC data sources? Specifically, I need to work with an Access database that for various reasons can't be upsized to SQL. This MSDN page says: The .NET Framework includes ADO.NET providers for direct access to Microsoft SQL Server (including Entity Frame...

Error running edmgen on entity framework ssdl, csdl and msl files

I have created a Entity Framework mapping based on the book "Microsoft Entity Framework in Action". The OrderIT DB is available for download from the link. I am on VS 2010 RC and this is my first serious try of EF. But I keep getting an error "Object reference not set to an instance of an object. Model.edmx" I have broken the...

ASP.NET ViewModel Alternative

In Django/Python, if I had the following model class Model1: id = char field name = char field creation_time = datetime field I can create a form (view model) like the following class Model1Form(Model1): exclude = {'id', 'creation_time'} I then pass it into a view/template and it would ignore id/creation_time In...

Can someone show me example for running a stored procedure twice and get diff results?

Hello For the past few weeks I have been really struggling doing something that should be really simple! I have a stored procedure in a database which I call twice. Each call results in totally different data. I need the entity framework to treat it like this At the moment it caches everything So I am going to ask for help in a diff...

What is the Include(..) method not getting found, on my IObjectSet object, in this Entity Framework code?

Hi folks, i'm trying to eager load some child entity, and when I try to add the Include() method, i'm getting a compiler error (ie. it can't find it). er ... can anyone help me out on this one, please? ...

Entity Framwork 4 - Not always updating boolean property using ApplyCurrentValues

I have a simple entity for a Country that is produced by Entity Framework 4 using VS 2010 RC. It looks something like the POCO below. public class Company { public int ID { get; set; } public string Name { get; set; } public string ISOCode { get; set; } public boolean Active { get; set; } } My repository code is below....

Entity Framework object limitations in aggregate LINQ query

I have a rather complicated query that I'd like to have return some particular types. Mostly concerning date / time calculations or string values, the Entity Framework seems to be spitting the dummy when I try anything further than a System.DateTime type: The specified type member 'Date' is not supported in LINQ to Entities. Onl...

InvalidOperationException with delete related objects

Hello I'm trying to delete all "Usergroup"s that belongs to one "User" and then add new "Usergroup"s. public void SaveUserUsergroups(int userID, int[] UsergroupID) { User uo = _entities.Users.Where(x => x.UserID == userID).First(); uo.Usergroups.Load(); foreach(Usergroup ug in uo.Usergroups) ...

How to do recursive load with Entity framework?

Hi, I have a tree structure in the DB with TreeNodes table. the table has nodeId, parentId and parameterId. in the EF, The structure is like TreeNode.Children where each child is a TreeNode... I also have a Tree table with contain id,name and rootNodeId. At the end of the day I would like to load the tree into a TreeView but I can't fi...

POCO support in ADO.NET Entity Framework?

Hi All, I want to manually map my Entity Classes(POCO) to the Database tables usin ADO.NET Entity framework using the XML mapping file. Is it possible to do so, as I have heard there is no POCO support in ADO.NET Entity Framework for VS2008( AM I Right?).....I want to use POCO classes in my project ad use the entity framework as an ORM....

EF 4.0 UpdateException

Hi I'm using EF 4.0 within VS 2010 RC. I have pretty simple POCO class structure with few dependencies. Each POCO class has a base generic class (EntityObject or ValueObect) with property ID. I have several CRUD tests and only one of them works. This one is very simple where object does not have any dependencies. But when I test somethin...

Cleanest way of updating many entities (of the same type) on one page with Entity Framework and ASP.NET MVC?

Lets pretend we have a /Cart/Checkout view that lists every Product in the Cart, plus a TextBox with the Quantity (in my real world application I have more than Quantity). How would you update the Quantity? I have used the following code, but I'am looking for a "cleaner" way of doing it. View <% int i = 0; foreach(var product in Model....

How can I handle an entity with other entities as children over different application layers.

If I detach the context I loose all of the relationships and if I don't I can't save later because the entity's context is disposed... This is an example of my code Public Sub Save() Using ctx As HMIEntities = New HMIEntities ctx.AttachUpdated(Me) //I use this extension method that works fine if I detach in the get method...