Hi Guys,
If i have the following entity:
public class PocoWithDates
{
public string PocoName { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime LastModified { get; set; }
}
Which corresponds to a SQL Server 2008 table with the same name/attributes...
How can i automatically:
Set the CreatedOn/LastModifi...
We have two entities with identical columns but the entity name is different. Can i create 2 entity using the first entity instance ?
We tried doing .AddObject("Entity2 name",entityOneinstance) but it is failing.
Please suggest whether this is possible or any other approach.
Thanks in advance
...
Hi Everyone
I am stuck here.
Is it possible to map data from 2 different tables to 1 entity in Entity Framework 4.
I have a bunch of employees in one table, and in the other I have som project information.
I would like to combine these 2 tables in one Entity, and keep the tracking features etc., is that possible?
I do not want to use...
I'm using the CTP4 code first EF framework, but I'm having problems getting lazy loading to work. Reading up on it, it should be simple, but it's just not
public class Folder
{
public int Id { get; set; }
public string Name { get; set; }
public int? ParentFolderId { get; set; }
public virtual IList<Folder> ChildFolders...
I'm trying to return a boolean value using the following query:
var q = from inmate in context.Inmates
select new
{
inmate.Id,
IsCrazy = inmate.Certified != null
};
IsCrazy should be true only when the optional Certified navigation property is not null. However, IsCrazy is always being r...
I have an ASP.NET MVC 3 Beta website using SQL Server CE 4.0. With both ScottGu's NerdDinner example and my own code, I will sometimes get the following exception as soon as I try to access the database:
File already exists. Try using a different database name.
[ File name = D:\Sourcecode\NerdDinner\NerdDinner\App_Data\NerdDinners.sdf...
I'm using EF4 to update a table with blob field. My code snippet is below:
public void SavePolicyDocument(int policyID, int batchID, byte[] file)
{
PolicyDocument policyDocument = GetPolicyDocument(policyID, batchID);
policyDocument.DocumentImage = file;
myEntities.PolicyDocuments.ApplyCurrentValues(policyDoc...
Can anyone help out with what the C# code would be to implement this SQL as Entity Framework Linq in the abbreviated form? (e.g. where you have the "." notation such as xxx.where(... etc)
SELECT PN.Name, Sum(U.Amount)
FROM Usages as U, ProcessNames as PN
WHERE PN.Id == U.ProcessNameId
AND U.Datetime BETWEEN '2010-01-08' AND '2010-1...
I currently have an n-tier application using entity framework 4.0 and we're looking at synching the contents of database between redundant servers. Does anyone have any experience on tips on how best to approach a solution?
...
Hi
I'm building out a stock management system at the moment, using Entity Framework 4.
A little background, my entities go a bit like this (only showing needed info)
Product --> ProductLocations
WarehouseLocation --> has many ProductLocations
Each ProductLocation has a Quantity
What I'm trying to do is have it so that when you call...
I have two IQueryables:
Ingredient:
IngId
Description
AvailableIngredient:
IngId
I already have an IQueryable for Ingredient:
var ingQuery = from i in context.Ingredients
select i;
How can I add a join to his so it filters by AvailableIngredient (i.e. an Inner Join)? I know how to do it if I had to join all the t...
Using Entity Framework 4.0 in C# / .NET 4.0.
Within my Entity model, I have an object (MyObject) that is part of a one-to-many relationship that produces a Navigation Property of the type EntityCollection<OtherObject>. Snippet of the generate code:
public partial class MyObject : EntityObject
{
/* other code */
public EntityC...
I'm working on a site and there are two projects in the solution a business logic project and the website project. I understand that I want to keep the entity context out of the web project and only use the business objects the framework creates but I can't figure out how to save a modified object this way.
Let's say my entity model cre...
I Use entity Framework 4.
I would like to be able to create a function that return an Expression func that will be use in a lambda expression.
var ViewModel = _db.Suppliers.Select(model => new {
model,SupType = model.SupplierType.SupplierTypeTexts.Where( st => st.LangID == 1)
});
I would like to mak...
I have two tables:
CREATE TABLE `Vehicles` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
... Other columns
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
And:
CREATE TABLE `VehicleOptions` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`VehicleID` int(10) unsigned NOT NULL,
...
There are several of books out on EF4. There are large differences between CTP3 and CTP4.
The CTP4 came out in July, so is:
Pro Entity Framework 4.0 by Scott Klein (Paperback - 15 Mar 2010)
Entity Framework 4.0 Recipes: A Problem-Solution Approach (Expert's Voice in .Net) by Larry Tenny and Zeeshan Hirani (Paperback - 19 May 2010)
...
Hi there,
I wonder if anyone can help me?
I am having problems understanding why i need to issues DetectChanges on my POCO (non proxy) entities.
Of course i have this line to ensure that proxies are not returned.
context.ObjectStateManager.GetObjectStateEntry(order).State
And doing some research it appears if i need to check the...
I'm having quite a bit of trouble trying to get inheritance to work in EF4. The original model is quite large, however I have managed to replicate it in a model of just two entities.
Essentially the two tables are "Asset" and "Questionnaire". Questionnaire inherits Asset (i.e. Questionnaire is an Asset). They do this by Questionnaire ha...
Hi Guys,
I'm attempting to test my repository using an in-memory mock context.
I implement this with an in-memory Dictionary, as most people do. This implements members on my repository interface to Add, Remove, Find, etc, working with the in-memory collection.
This works fine in most scenarios:
[TestMethod]
public void CanAddPost()
...
My Entity object has user-assigned id key instead of database-generated id. Proxy created by Visual Studio 10 shows the following:
[DataContract(Namespace="http://schemas.datacontract.org/2004/07/Simplet.Web.Models")]
public sealed partial class BusinessType : Entity
{
[DataMember()]
[Editable(false, AllowInitialValue=true)]
...