I have the following DB structure (simplified version):
Comments - CommentId, UserId
Users - UserId
UserDetails - UserId, Address, Phone, etc.
I am using EF 4 with POCOs. The User property of the Comment class is marked as virtual (to enable lazy loading for it). However, I want when the User property is loaded (lazy) also its UserDet...
Hello,
How can I get the 1st EntityKey name for an Entity for Entity Framework 4 because I'm building a repository system and I wanted to get an item by Id (which is the primary key oin EF is the 1st entitykey for the entity)
I'm using this code
public virtual TEntity GetById(string keyName, Guid entityId)
{
var ent...
I'm currently doing some research on usage of db4o a storage for my web application. I'm quite happy how easy db4o works. So when I read about the Code First approach I kinda liked is, because the way of working with EF4 Code First is quite similar to working with db4o: create your domain objects (POCO's), throw them at db4o, and never l...
I am struggling with the following use-case:
User amends an existing order. The order is complex - lots of related 'entities' (addresses, post options, suppliers, makes, models, various items etc). Across multiple http posts.
User wants to discard the changes.
--
I have an order entity and as the user is editing this I am making vari...
this is a simple question (I think), but I have not been able to find a solution. I know with other types of queries, you can add a limit clause that makes the query only return up to that many results. Is this possible with an entity query?
var productQuery = from b in solutionContext.Version
where b.Prod...
I have been using Entity Framework CTP with Code-First as in this tutorial by Scott Guthrie and another by Scott Hanselman (can't post the link, but google "Simple Code First with Entity Framework 4 - Magic Unicorn Feature CTP 4"). This is working perfectly for the main MVC application, but I am now trying to add a testing project, that ...
I have a very simple mockup I'm making for a client that uses the Northwind database. I have an EDMX file with three entities: Products, Categories, and Suppliers.
I'm trying to create a page that has a GridView that shows the products, including the category name and supplier name. With LINQ to SQL I can have the LinqDataSource control...
I'm trying to build a simple proof-of-concept "business application" in Silverlight and I keep running into a wall in trying to get data in and out of the database. I'm currently trying to learn WCF RIA Services, but I'm stuck because I can't get Entity Framework to work with existing tables in my database (they don't show up in the mod...
Hey, I have a table called products that has a relationship with itself. This table stores products, their sub-products, and then sub-sub-products. When a user searches for the top-most product, this query is supposed to return the parent, its children, and its children's children. Now, my query works, but I am new to the entity framewor...
As it stands now, the CLR UDTs including HierarchyID aren't supported in Entity Framework 4. HierarchyID.ToString() is useful, but breaks down once any item has 10+ siblings (the basic structure is /3/4/12/ or /3/4/2/ so the 12th node will sort before the 2nd node).
A little more about potential options:
Bring back hierarchyID as ...
Hi guys,
I am working with VS 2010, Entity framework, SQl-Server 2005, ASP.Net web forms. Currently, I am working on the Data access layer library which soon will be a web service, using Entity Framework collaboration with different design patterns like repository pattern and some best practices that posts in different blogs. I am also ...
Greetings,
I'm having a hard time with the ADO.NET Entity framework.
I want to do a relation between 2 existing items, in a Many to Many table.
Example:
create table A(key int, value varchar(10));
create table B(key int, value varchar(10));
create table A_B(keyA int, keyB int);-- those are FK..
Now I want to do the relation between...
Hi,
I've been stuck with this problem for over a week now. Hopefully some one can point me in the right direction.
I start with a brief description of my schema.
Asset 1--->1 Address *-->1 Area *-->1 Region *-->1 Country
Package 1-->* Asset
Using Self Tracking Entity (STE) + WCF.
Steps:
Call data store for a list of assets.
Call ...
I'm trying to filter down the results returned by EF into only those relevant - in the example below to those in a year (formattedYear) and an ordertype (filtOrder)
I have a simple set of objects
PEOPLE 1-M ORDERS 1-M ORDERLINES
with these relationships already defined in the Model.edmx
in SQL I would do something like...
select *...
We are developing a service layer for a new system that will handle all interactions with the MSSQL (2005) database. We are a bit perplexed as to how to capture all of the 'who done it' information that is required by our users in some of our legacy audit tables. While we could pass in the users name that was modifying data and log the...
Hi,
I have had a play with the Entity Framework and the MySQL driver. Excuse me if this is a silly question. Table adverts has a FK to the PK of vacancies. Both fields are marked as NOT NULL. I am performing a simple join:
var qry = (from vacancy in context.vacancies
join advert in context.adverts on vacancy...
This may be a really elementry question but whats a nice way to include multiple children entities when writing a query that spans THREE levels (or more)?
i.e. I have 4 tables: Company, Employee, Employee_Car and Employee_Country
Company has a 1:m relationship with Employee.
Employee has a 1:m relationship with both Employee_Car and Em...
I am looking to be able to load an entity by ID using generics and property reflection but am unsure how to accomplish this task using Entity Framework 4.0.
I have a method in my abstract method as such:
public abstract T GetById(object id, TestContext context);
Currently, since it is abstract, I have to implement this method in ever...
With EF Code First CTP 4 I've created a simple project. This project consists of 2 classes, one inherited from other.
I wish to store the data in separate tables, but the default of EF 4 is to map/store these two entities in the same table.
With .ToTable(), I can change this behavior, but with this I have a side effect: when I persist ...
I have several entities generated from my Entity Framework data model. In the .edmx file I can see the properties that are flagged as primary keys. My POCO's/custom context are generated from this and the T4 templates.
I am looking for a way to find out the primary keys of my entities using reflection with Entity Framework 4.0. Is there...