We are undergoing a migration from classic ASP with SQL and Sprocs. Our choice fell upon c#.net 4 Webforms with Entity Framework 4.
My question is how to handle the context. Example:
Calling repository function GetProductById(), which open up a new context (using) and then we change something on the object and we save it.
When we save...
When I developed a site with VS 2008 it happily connected to a the webservice in the solution, then connected to the database (using ADO.Net Entities) and ran my query.
Now I come to rolling out the site. When it connects to the webservice it is connecting as NETWORK SERVICE - which I don't want - I need it to connect as 'MYCREDENTIAS'....
For Entity Framework associations, are Independent Associations or FK Associations recommended?
I have been receiving an error with the multiplicity I tried to use in an independent association.
...
When i create an entity data model and select Add Code Generation Item i don't see any ADO.NET Self-Tracking Entity Generator(i only see ADO.NET EntityObject Generator). What may be the problem?
I am using visual studio 2010 ultimate. I installed and then uninstalled ado.net entity framework ctp 3.
...
Consider an application dealing with houses and pictures. An entity named House has a 1:n relationship to HousePicture.
The application allows the user to create and edit a House, and add/remove HousePictures.
[HttpPost]
public ActionMethod Edit(House h)
{
//get an attached entity from the DB first.
House original = db.Houses.Sin...
Trying to get the method to check this way:
Membership.ValidateUser(long companyId, string username, string password)
As an overload. I already have a class that implements the MembershipProvider, MembershipUser, and RoleProvider classes (with overrides), but I can only cast the result of the Membership.ValidateUser return into what...
I am using Entity Framework 4.0
Many of our tables have a column called RowID, used by the DBA to track stuff. The column is NON NULLABLE has a database default value that maps to a function.
The problem is, the EDMX Model requires this property to have a value on the Entity, making construction of the object difficult.
I have read ma...
I have an object that inherits the EF ObjectContext object and I want to call a Function Import I created. Anyone know how to do that? Do I have to use ExecuteFunction()?
Thanks!
...
Is there a way to create a Function Import on an Oracle stored procedure that is overloaded? I have a login sp that is overloaded three times. I tried to create a Function Import for it but EF doesn't let me pick which sp I want to create. It creates the one with the least amount of parameters. Any ideas?
Thanks!
...
I get the following message:
{"Entities in 'Entities.ApprovalRequests' participate in the 'FK_ApprovalRequest_Audit' relationship. 0 related 'Audit' were found. 1 'Audit' is expected."}
I'm stumped, does anyone know what to make of it?
My EDMX had the FK and is correct, yet every time I get this message.
How one would go to debug thi...
I'm playing around with the EF 4.0 POCO CTP (from here).
I'm constructing an ObjectContext using the ContextBuilder class like so
context = new ContextBuilder<T>().Create(new SqlConnection(...));
T is of type ObjectContext. When I try to get a reference to all the mapped entities in the context like so:
var entities = context.Met...
it seems if i use an custom class as base of an entity,the ObjectContext.CreateObjectSet will fail with stackoverflow exception
code is:
// This is generated by EF4 and i modify it to my custom class
public partial class EntityA : GClass<EntityA>
{
......
}
public partial class TestEntities : ObjectContext
{
public ObjectSet<E...
The only way that I know of to make an async call using Linq to SQL is to compose an IQueryable and then ask the data context for the equivalent SqlCommand using GetCommand, which provides the BeginExecuteReader method. This approach didn't work for stored procedures and required some hackery to essentially use reflection to generate the...
I have a message table that self joins to itself where Message.ID == Message.Parent. So I have 1 Message with several ChildMessages. This is set up nicely with a Navigation property.
The code is currently:
var message = from m in soe.Messages.Include("ChildMessages")
where m.ID == id
&& m.IsActive
...
Hi,
I am using Entity Framework 4.0 and trying to use the "Contains" function of one the object sets in my context object. to do so i coded a Comparer class:
public class RatingInfoComparer : IEqualityComparer<RatingInfo>
{
public bool Equals(RatingInfo x, RatingInfo y)
{
var a = new {x.Pl...
I am using EF 4.0 and POCO's. I stumbled across this error while inserting to records into the data base.
Property accessor 'QualityReasonID' on object 'BI.Entities.QualityReason' threw the following exception:'Object does not match target type.'
There errors occur on the Databind to a GridView after saving a new record to the databas...
I have a timestamp (rowversion) column (called t_stamp) in my tables. I use EF4 as my ORM. I see that the timestamp fields become byte[] properties on my objects.
I want to use LINQ something like this:
byte[] last = 0x00782342
from o in _db.Objects
where o.t_stamp > last
select o
But that doesn't work because I can't use > on a byt...
We have an ASP.Net MVC2 web site, and are utilizing EF4 for database access, etc. Being new to EF4, we have come across the EF4 POCO concept, however do not fully understand it.
In general, I've heard POCO defined as objects "not dependent on an external framework". In the case of EF4, I'm guessing this means that POCO would imply som...
I have a fairly complex LINQ to Entities query I'd like to try compiling because it's a bit slower than I'd like.
I build it in a series of steps though. Here's a simple example:
public static List<Employee> GetEmployees(EntityContext ctx, bool showTerminated)
{
var q = ctx.Employees;
if(showTerminated==false)
{
q ...
I have a hard time telling what operations in linq cause a SQL command to be issued to the database.
I know calling ToList() or iterating w/ foreach will cause the query to run but do Select and GroupBy cause the code to execute on the database?
...