Hi all,
Consider two tables, Product and Supplier. To get the required data for a grid view I need to do something like the following code snippet. SupplierID is a foreign key in the products table, but needs to be displayed in the user friendly SupplierName from the Supplier table.
SELECT Product.ProductID, Product.ProductName, Produc...
I want to create a copy my object in my DB with using Entity Framework
first I got my "Book" from DB
var entity1 = new testEntities();
var book= entity1.Books.First();
entity1.Dispose();
then, I tried to add this object as a new object
var entity2 = new testEntities();
book.Id = 0;
entity2.SaveChanges();
entity2.Dispose();
Also I ...
I have a WCF service that uses the entity framework to retrieve records from the database and map them to POCO objects. These POCO objects are then returned to the client application.
Lets say the client application changes some properties on one of these POCO objects then sends it back to the WCF service to be saved. As far as I can se...
I'm just starting with Entity Framework and there's a thing I don't understand:
They say LINQ to SQL is being discontinued. But Entity Framework is being activelly developed and recently they released version 4.0. As far as I know, LINQ is the default method of expressing queries in Entity Framework. How come? What are they gonna do? Th...
I am utilizing Entity Framework 4.0 and WCF. I am new to using Entity Framework and am more familiar with NHibernate. However, I am concerned about detached instances of objects when performing an update.
I have looked on various websites where they retrieve an object, attach the instance to their context, and set all properties to be ...
First some brief background: I have an existing ASP.NET MVC 1 application using Entity Framework v1 which works fairly well, though because there are getting on to 40 tables the .edmx is getting unwieldy and prone to corruptions with the Visual Studio 2008 designer.
What I want to do is to see if it's feasible to migrate the DAL to use ...
I am new to Entity Framework 4, and I am wondering, what's the best way to organize my data layer--the code that accesses EF4?
At this point, my data layer is set up like this:
DataStore class: Holds a reference to the EF4 ObjectContext, and contains methods to open, close, and persist the ObjectContext to storage.
Repository classes...
We have a Model project with 4 EF models in it. Notice the properties folder starts out empty.
With the Model project selected I open the data sources window. Three datasources are created and displayed. You can see how it creates a .datasource file for each model, except the eFinancials model.
Any ideas why this happens. There i...
I have two identical controller actions and two nearly identical views (one just has a different javscript file with it). One view works just fine, but the other gets hung up on this EF error:
A relationship multiplicity constraint violation occurred: An EntityReference can have no more than one related object, but the query returned mo...
Hi,
WCF Data Services and Silverlight client BeginSaveChanges does not work with stored procedure as UpdateFunction of a View as entity in the entity model?
I have specified stored procedure as UpdateFunction in the entity model specified as update function of a view. From the Silverlight client I call WCF Data Service. I also have a M...
Hi,
I have EntityTypes generated from a database using Entity Framework 4. I would like to use Cache to store some of these EntityTypes for performance reasons. Is it safe to do the following provided that the object will be used for read-only actions:
context.Students.MergeOption = MergeOption.NoTracking;
var students = context.Student...
I am currently integrating an entity component system, as seen here, with a physics engine and a graphics engine. This was all fine until recently deciding that the physics should be running in its own thread. (Thanks Glenn Fiedler!)
As it is now I am simply locking a mutex shared by all subsystems when accessing components.
Snippet fr...
Hi,
I have a Silverlight client with a grid getting data from WCF Data Service. Works fine.
However if I want to update some changed grid row, the service data context UpdateObject is not working:
DataServiceContext.UpdateObject(MyGrid.SelectedItem);
foreach (Object item in DataServiceContext.Entities)
{
//
}
...
I have multiple clients and a central server.
The server is using a WCF data service to allow clients to update data. An EF Model interfaces the server Data services. Clients use the below code.
svr.AddToTable(NewData)
svr.SaveChanges()
I need to let the server DB add columns to tables and allow clients to continue to work with the d...
I want to create Table-Per-Type database table inheritance.
Simply base table RowElement will have 2 children tables. First child table Lyrics will inherit all parents RowElement's columns and will just add one more column. Second child table ChordUse will only many-to-one relationship to table Chord.
This is how my database schema lo...
I've created a generic ObjectSet<T> in my generic repository.
What I would like to get is the name of the EntityKey of ObjectSet<T> so that I can use it in the DataContext.GetObjectByKey.
I've searched around and dug deep, but I can't seem to find this value anywhere in the ObjectSet class.
...
Hi,
I would like to know the pros and cons of using EF4 Code-First approach. Can we duplicate all features that EF4 generated classes offer like Lazy Loading, loading related entities, etc?
Thanks
...
I am trying to create a record in the db that has a predefined primary key value. I know how to do this with sql, but I was wondering if EF can do this for me? Otherwise, I will have to create a stored proc for the inserts.
...
I am trying to get a list of all objects in the database of a specified type. I have done this before when the type was known at compile time, but now I am trying to pass a type into the method and have the method return all the records of that specified type, and I can't get it working. I have tried the following:
public IList<W...
Hi all,
I am trying out EF 4.0.I have an Employee Object and using EF I am getting the Employee ObjectSet by simply calling
Context.Employees
Now the above call will spit following sql query
select * from Employees
The above query works fine and I don't have any complains on it however as you know this will not be performant...