When you have code like this:
Something something = new Something();
BlahEntities b = new BlahEntities()
b.AddToSomethingSet(something);
b.SaveChanges();
how do run that addition inside a transaction?
...
I was wondering what the best way to use transations with the entity framework.
Say I have three repositories:
Repo1(ObjectContext context)
Repo2(ObjectContext context)
Repo3(ObjectContext context)
and a service object that takes the three repositories:
Service(Repo1 repo1,Repo2 repo2, Repo3 repo3)
Serive.CreateNewObject <- cal...
I'm trying to create a member page for updating account details. I want to populate a form with the member's data, but I don't know how to set a filter on the EntityDataSource to limit the query.
When I set the select statement based on the member ID, I get the error
Select cannot be set if EnableDelete, EnableInsert, or EnableUpdate...
Hey everyone,
I'm trying to create some CRUD functionality for a legacy database and using the Entity Framework as an ORM tool. One table, 'Sites', has a Guid type 'Id' column which is never seen by the users and an integer type 'SiteId' which the users use to identitfy a Site.
For god knows what reason the numeric SiteId column is of ...
First of all there is error message:
The entity or complex type 'AdventuresWorks.ProductSubcategory' cannot be constructed in a LINQ to Entities query.
Here is mu POCO class:
public class ProductSubcategory
{
public Int32 ProductSubcategoryID { get; set; }
public Int32 ProductCategoryId { get; set; }
p...
Hi
Is it possible to use a function import in a where clause in entity framework? I have tried the following, but I get a rather cryptic exception to which I cannot find any information about:
var q = MyContext.MyEntities.Where("MyContext.MyFunction(it.ID)")
(The function is set to return a Boolean)
System.Data.EntitySqlException: '...
I have an application that allows users to enter time they spend working, and I'm trying to get some good reporting built for this which leverages LINQ to Entities. Because each TrackedTime has a TargetDate which is just the "Date" portion of a DateTime, it is relatively simple to group the times by user and date (I'm leaving out the "w...
I am using the Entity Framework in a web application that utilizes SQL server 2000, 2005, and 2008. When I create a new EDMX file using anything other than 2008 (version of the first edmx created) I receive error 0172: All SSDL artifacts must target the same provider. The Provider 'MyDatabase' is different from ' MyDatabase ' that was en...
I've decided to use Entity Framework for O/R Mapping, and DataAnnotations for validation in my project, and I have now encountered an odd problem when trying to implement this.
This is what I've done:
I have the following entity type
Contact
*******
Int32 Id (not null, Entity Key)
Name Name (not null)
Address Address (not null)
Strin...
I've been running a trace on some of the queries Linq is generating and they seem very unoptimized and clumsy.
I realise you dont know my data structure but is tere anything immidiatly wrong with the following linq query
IQueryable<Tasks> tl = db.Tasks
.Include("Catagories")
...
I'm trying to fetch some records from MSSQL DB using EntityObject with EntitySQL query.
The field i'm using to filter is type of datetime.
The generated query projected without millisecond, to the SQL Server returns nothing.
When i'm adding the milliseconds, i get results.
How can i use the EntitySQL to get result without the millisecon...
Hello !
i've a trouble with linq, i'll explain on example :
i have a database table called Employee which got FirstName and LastName columns,
and a method to search employees which gets a nameList list as argument, the elements in this list are names formatted like this one "Fred Burn", or this1 "Grim Reaper",
already tryed these appro...
When initialize an entity framework context.
One is to initialize at class level, such as
public class EntityContactManagerRepository : ContactManager.Models.IContactManagerRepository
{
private ContactManagerDBEntities _entities = new ContactManagerDBEntities();
// Contact methods
public Contact GetCo...
I have the following Model:
Entities:
Product (Contains basic data for
products: price, etc)
Attribute (Contains data for all possible optional attributes)
ProductAttribute (Contains data for optional attributes of a product, eg.
Color, Model, Size). ProductAttribute
is essentially a many to many
relationship with payload (ProductId,
...
I am losing my mind. It's a simple scenario:
Entity definition (generated)
// this class is obviously generated by the designer, this is just an example
public class SomeEntity {
public int SomeEntityID { get; set; } // primary key
public String Property1 { get; set; }
public String Property2 { get; set;
}
.. in aspx file
<asp...
Currently for ASP.Net stuff I use a request model where a context is created per request (Only when needed) and is disposed of at the end of that request. I've found this to be a good balance between not having to do the old Using per query model and not having a context around forever. Now the problem is that in WPF, I don't know of a...
string[] usersToAdd = new string[] { "asd", "asdert", "gasdff6" };
using (Entities context = new Entities())
{
foreach (string user in usersToAdd)
{
context.AddToUsers(new User { Name = user });
}
try
{
context.SaveChanges(); //Exception thrown: user 'gasdff6' already exist.
}
catch (Exception ...
I have an ADO .Net Entity Data Model for my database. In this Model I have three related tables:
"Users" Table containing UserId and other details.
"Run" Table that contains RunId, ApproverId and other details
"RunToUser" that contains UserId and RunId columns
The relationships are as follows:
Users.UserId is a one to one relationship ...
I wonder what is the most useful class in the Google collections framework?
...
I am trying to perform a query using linq to entities to that an entity/table doesn't contain the same values before I update it.
The structure of the database is as follows:
Users User_IPAddresses IPAddresses
----- ---------------- -----------
UserID >------ UserID ------< IPAddr...