Hi.
I have public interface:
public interface IEntity
{
int ID { get; set; }
string Name { get; set; }
bool IsEnabled { get; set; }
}
which is implemented by some EF entities(throug partial class) and one extesion method:
public static IEnumerable<SelectListItem> ToSelectListItems<T>(this IQueryable<T> entities, int? sel...
Does EF 4 support unidirectional one-to-many associations, as in:
public class Parent
{
public int Id { get; set; }
public string Something { get; set; }
public List<Child> AllMyChildren { get; set; }
}
public class Child
{
public int Id { get; set; }
public string Anotherthing { get; set; }
// I don't want a back-reference...
Hi everybody
I use EntityFramework as ORM and I have simple POCO Domain Model with two base classes that represent Value Object and Entity Object Patterns (Evans). These two patterns is all about equality of two objects, so I overrode Equals and GetHashCode methods. Here are these two classes:
public abstract class EntityObject<T>{
...
Is there any ORM that offers APIs to be used programatically?
In my situation, a user will be helped through a wizard to define some entities. Thereafter those entites will be created in a database in form of tables (there will of course be some improvization).
I need an ORM that offers APIs for modeling and creating entities during ap...
One of the much-anticipated features of Entity Framework 4 is the ability to use POCO (Plain Old CLR Objects) in a Persistence Ignorant manner (i.e. they don't "know" that they are being persisted with Entity Framework vs. some other mechanism).
I'm trying to wrap my head around why it's necessary to perform association fixups and use F...
I have a POCO (Plain Old CLR Object)
public Foo
{
public virtual int Id { get; set; }
public virtual Dictionary<string, string> Stuff { get; set; }
public virtual string More { get; set; }
}
Using the model first approach (i.e. I don't have a data model yet), how would I handle persisting Stuff (Dictionary)?
...
So I am looking at creating a generic Interface to interact with my DataStorage of my objects one that I can swap out to use EF4 or SubSonic or NHibernate or some NoSQL option.
So I have an ERD and every table has an auto incrementing int column "TableNameID" that is the primary key I am trying to figure out how to get a single record...
I worked on a fairly large project a while back where we modeled the classes in Enterprise Architect and generated the (partial) POCO classes (complete with model-driven business rule validations), persistence (NHibernate mapping file) and DDL. Based on certain model attributes we could flag alternate generation strategies or indicate t...
I am trying to create a generic method using EF4 to find the primary key of an object.
example
public string GetPrimaryKey()
{
....
}
To Give more info I am working off of the Tekpub StarterKit and below is the class I am trying to get up and running
using System;
using System.Collections.Generic;
using System.Linq;
using System.W...
I'm using the Model First approach with EF 4 and hit a snag with two tables, Participant (singular because pre-existing from another app) and ActiveParticipants.
A Participant may or may not be associated with exactly one ActiveParticipant and vice versa.
When I create an association, everything seems to go well on the surface, but the...
I have a Page table and a View table. There is a many-many relationship between these two via a PageView table. Unfortunately all of these tables need to have composite keys (for business reasons).
Page has a primary key of (PageCode, Version),
View has a primary key of (ViewCode, Version).
PageView obviously enough has PageCode, Vi...
I have a simple Entity Framework 4 unit test that creates a new record, saves it, attempts to find it, then deletes it. All works great, unless...
... I open up SQL Server Management Studio while stopped at a breakpoint in the unit test and execute a SELECT statement that returns the row I just created (not SELECT FOR UPDATE, not WITH ...
It seems that lazy loading is enabled by default in EF4. At least, in my project, I can see that the value of
dataContext.ContextOptions.LazyLoadingEnabled
is true by default. I don't want lazy loading and I don't want to have to write:
dataContext.ContextOptions.LazyLoadingEnabled = false;
each time I get a new context. So is t...
Hi,
Trying to implement some nested loops that are spitting out good old nested html table data. So the question is; What is the best way to loop through lists and nested lists in order to produce easily maintainable code.
It can get quite narly quite fast when working with multiple nested tables or lists.
Should I make use of a HTML he...
Using Entity Framework 4 with stored procedures and SQL Server 2008 SP1... When running SQL Server Profiler (TSQL_SPs template), the lines that show my stored procedure call and its statements say that this happened in DatabaseID = 1 (Master) but it is actually happening in my application database. The procedures execute properly and r...
I tried out EF back in .NET 3.5 SP1, and I was one of the many who got frustrated and decided to learn LINQ to SQL instead. Now that I know EF is the "chosen" path forward, plus EF 4.0 has some exciting new features, I'd like to migrate my app to EF 4.0.
Can anyone suggest any good resources that are specifically targeted towards 4.0 a...
I updated my Model with my Stored procedure and in the model browser I can see it has a Function import as well.
My SP inserts a record if none exists and returns a 1 else returns 0, pretty simple I think.
SP
CREATE PROCEDURE [dbo].[User_UpdateMessage]
(
@UserId int = 0,
@UserId2 int = 0,
@Success bit = 0 OUTPUT
)
AS
BEGIN
SET NOCOUNT...
We've got a database with over 1000+ tables and would like to consider using EF4 for our data access layer, but I'm concerned about the practical realities of using it for such a large data model. I've seen this question and read about the suggested solutions here and here. These may work, but appear to refer to the first version of th...
I'm trying EF 4 with POCO's on a small project for the first time. In my Repository implementation, I want to provide a method AddOrUpdate that will add a passed-in POCO to the repository if it's new, else do nothing (as the updated POCO will be saved when SaveChanges is called).
My first thought was to do this:
public void AddOrUpdat...
My ASP.Net MVC 2 project references a Domain project where POCO business objects are defined and a Data project where EF 4 POCO persistence is implemented.
Things were running well until I had a little fussiness with my version control provider (rollback to previous version left me with merge conflicts). Now, upon launching the MVC 2 p...