So I'm trying to create a generic select by ID method for a base repository class. In order to achieve this I'm using EF4 with POCO's. I created an interface with a getter called Id and successfully modified the T4 template in order to have a generic Id property in all the entities that returns the PK.
The problem comes when I use the q...
I am using EF4 CPT4 Code first and I have setup my ObjectContext to return IObjectSet so I would be able to Mock and test my repos. However, I now noticed that I am unable to use the .Include() method for eager loading like I would be able to if I used ObjectSet.
Is there a way to make this work???
Edit:
I added this extension method:...
Hi community,
is there an possibility to call the Math.Sin()-function in a Linq To Entites (Entity Framework 4) -Query?
I've read, that the current Entity Framework 4 doesn't implement this function.
Maybe there's a workaround to this solve problem?
(I don't want to invite all entries in the memory.)
Thanks and best regards
...
I'm using ModelBuilder to map an existing database to POCOs. I have courses, students, and meetings. Here are the tables
CREATE TABLE Courses (
CourseID int,
Name string)
CREATE TABLE Students(
StudentID int,
Name string)
CREATE TABLE Courses_Students (
CourseID int,
StudentID int)
CREATE TABLE Meetings (
...
I have the exact same problem as described in this post (event content / tags objects):
http://stackoverflow.com/questions/110314/linq-to-entities-building-where-clauses-to-test-collections-within-a-many-to-ma#131551
I am getting the Exception:
Unable to create a constant value of type 'XXX.Tag'. Only primitive types ('such as Int32, ...
I have a database table and a corresponding entity class (POCO with change tracking Proxy) with a member which acts as a counter:
class MyEntity
{
public virtual int ID { get; set; }
public virtual int Counter { get; set; }
}
There is a function in my web application which must fetch this entity by ID, read the Counter (which ...
I have the following tables (condensed for readability):
Call
ID
CallerName
CallerTime
Categories
ID
CategoryName
CallCategories
CallID
CategoryID
When I modeled these in the Entity Framework the mapping talbe "CallCategories" was left out. I am stumped on how to get a record added to this table via the EF.
I have gotten this far...
Why does entity framework pluralize all the class names and capitalize the first letters by default? What are the advantages of doing this ? Probably a stupid question...but just out of curiosity?
...
Is thera any good way to write Unit Tests for controllers and EF4 without POCOs?
I have few repositories, controllers with injected repos and i'd like to write some unit tests (i know, tests should be written before, but noone's done it).
To test controller i have to mock HttpContext etc. and inject repo with Mocked ObjectContext gener...
Hi,
I am using EF4. Just a quick question, is this a really good framework? We currently make use of a business and data layer as separate projects. The fact that everything is in 1 file in EF4 is this a good thing? How do you distinguish between your business and data layer?
How is it possible for more than 1 developer to work on ...
I am trying to create a generic method that will retrieve an item by its id:
public T GetByID(int id)
{
return (T) context.GetObjectByKey(
new System.Data.EntityKey(context.DefaultContainerName + "." +
context.CreateObjectSet<T>().EntitySet.Name,
"ProductID", id));
}
Basically I am able to infer ...
I am struggling to create a One-to-One relationship in EF4.I keep getting errors like this:
Each of the following columns in table XXX is mapped to multiple conceptual side properties:
XXX.Id is mapped to <XXXYYY.YYY.YYYId, XXXYYY.XXX.Id>
Given I have a classes Person and PersonDetail that relate to tables of the same name, and the Id'...
I've got an Entity Framework 4 EDMX using Table Per Type inheritance between one base table and two inheriting tables that looks something like this (table names changed and a lot of unrelated stuff removed).
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Run...
Can I join the list object in .net collection with the enity object in EF for example
var prodts = from req in Product
join prod in context.ProductApplications on req.ProductGUID equals prod.ProductGUID
slect req;
Product is the lsit object. and context.ProductApplications is the Enity object.
Can I j...
I found this similar question here, but this is really old.
Was it implemented in the latest version?
...
Hi,
I just started playing around with the CTP4 and Code-First. I have the following setup for a possible dating site:
public class User
{
[Key]
public int Id { get; set; }
[Required]
public string LoginName { get; set; }
[Required]
public string Firstname { get; set; }
[Required]
public string Lastname {...
I've published wcf dataservice project to IIS7 with .NET 4 installed on that server. Everything worked fine, but when i called SaveChanges from client, service returned error:
Server Error in '/'
Application.Description: An error
occurred while accessing the resources
required to serve this request. You
might not have permiss...
In a WPF / EF4.0 / MVVM app I have a View that edits a Customer entity. What is the best way to set a property "bool IsCustomerInEditMode" in my CustomerViewModel short of acting upon OnChanging/OnChanged partial methods for every single individual property of the Entity? As far as I know there's no OnEntityChanging method...
Thanks!
E...
Using EF4. I have a situation where a linq to EF query with explicit joins won't work due to a many-to-many table. I'm not going to break the database design to suit EF, so I want to use the include method. However, that always seems to generate left outer joins and I need inner joins (simple context.Table1s.Include("Table2") where tab...
I am using entity framework 4 and Csharp. I have a datagridview in a windows form. The datagridview has a colomn with a combobox. The combobox is to hold an Entity object.
Usually I do the following:
dataGridViewComboboxColumn.DisplayMember = "DisplayThis"
dataGridViewComboboxColumn.ValueMember = "DisplayThisId"
But I want:
data...