ASP.NET linq Select with multiple joins

I've this database from EF code first, and now i have a difficult time getting my data. I have the following entities: Program : is a workout program that contains Workouts. Workout : is a day routine that contains a list of Sets. Set : is an Exercis

How can I compare only the time part?

This question already has an answer here: Using DateTime?.Value.TimeOfDay in LINQ Query 1 answer I'm storing a time span in Sql Server as two columns of type datetime. (start and end) So the date part of each column needs to be ignored. Given some c#

Error navigating in a single entity frame

I'm a newbie in ASP.NET MVC4. This is my problem: I have two tables as follow: `Users(Username, Password, Email, RoleId)` and `Roles(Id, Name)` Which Users.RoleId is foreign key references to Roles.Id This is my classes: [Table("Users")] public

SUM and DISTINCT of two different columns

I have a table Employee with say the following records EmpID Salary Date 10 2000 1/1/2011 10 2000 2/1/2011 20 2000 1/1/2011 I want to count the total number of employees and the total salary (based on some other parameters) Is there a easy way to wri

Entity Framework Code First lazy loading

I am having two object classes public class User { public Guid Id { get; set; } public string Name { get; set; } // Navigation public ICollection<Product> Products { get; set; } } public class Product { public Guid Id { get; set; } // Navigation pub

Object-oriented database models

UPDATED WITH CODE! I am developing a web application using ASP.NET MVC 3 and I want to create an object-oriented list using "ADO.NET Entity Data Model". I've created models by entity framework "Code-First" using "ADO.NET Entity Da

EF4 can generate a template from db using custom conventions

Is there a way in EF4.1 to generate Entity classes that follow custom naming conventions instead of exactly matching the db column names? We are starting to use EF4.1 for an existing project. We would like to follow our existing camel case convention

What is & ldquo; var & rdquo; in Entity Framework

I would like to ask what is "var" in this statement. var context = new MHC_CoopEntities(); var lists = (from c in context.InventLists select new { c.InventID, c.ItemName, c.InventCategory.CategoryID, c.UnitQty, c.UnitPrice }).ToList(); ListGridV

Unable to convert method group 'ToList' to non-delegated type

I'm trying to write a method that generates multiple invoices. This is for a college, where clients are enrolled with tutors in a class called Enrollments. With this method, I am trying to accumulate the monthly fee of the tutors clients multiplied b

Entity Framework Background in Singleton

I'm building a App that use Context of EF in Singleton Pattern like NHibernate work with Session: public class DbContextFactory { private static volatile DbContextFactory _dbContextFactory; private static readonly object SyncRoot = new Object(); publ

EF.Utility.CS.ttinclude and MSBuild

I am having troubles getting my MSBuild script transform a .tt file that references EF.Utility.CS.ttinclude. If i run the generation from within VS2010 it works fine, but when I run my custom build script via the command line I get. TextTransform "C:

Line number in LINQ

I have a linq query like this: var accounts = from account in context.Accounts from guranteer in account.Gurantors where guranteer.GuarantorRegistryId == guranteerRegistryId select new AccountsReport { recordIndex = ? CreditRegistryId = account.Credi

mvc3 data access

question: i'm building (or trying to build) a front end for an enterprise level web-app. the existing structure is driven by stored procedures (sql 2008 db). A stored proc is implemented as a class that ultimately handles the execution and the result

Entity Framework 4 Custom Logical Changes

I am trying to add some custom logic to my entities. Each entity has a CreatedBy & LastUpdatedBy property. I have added the code below which works fine if I am adding e.g. A Person and their Address in on go. However if I add the Person and call cont

Dynamically add the where clause in Entity Framework

I have this sql statement SELECT userID from users WHERE (name='name1' AND username='username1') OR (name='name2' AND username='username2') OR (name='name3' AND username='username3') OR .......... (name='nameN' AND username='usernameN') Hho can I imp

How to update the EF 4 entity in ASP.NET MVC 3?

I have 2 projects - a class library containing an EDM Entity Framework model and a seperate ASP.NET MVC project. I'm having problems with how your suppose to edit and save changes to an entity using MVC. In my controller I have: public class UserCont

LINQ Lambda Where () does not filter as expected

I'm trying to build a query using LINQ for EF to filter results based on some basic logic. For some reason, even with the following Where() functions being executed and setting the right parameters, all data is being returned instead of the filtered

Can not insert data with EF with master-detail relationship

Suppose I have 2 tables: Person(pid, ....) //Pid is identify colum as primary key Student(pid, Student_No,...) //pid is foreign key from Person, pid is a primary key too. Then use EF to generate entity model. THen try to insert new data with followin

EF 4.0 - Load Navigation Property of Navigation Property

I am attempting to perform the LoadProperty operation from my context to load a navigation property of a navigation property. My setup is that I have an EntityA, which contains a list of EntityB's, and each EntityB contains a list of EntityC's. I am

EF4 and database views

Sorry this is quite a vague question. Been trying to find information on using a View with Entity Framework 4. Want to use it as a read only view, no interested in inserting/updating/deleting... Would just like to use a POCO with a view... [Update] T

How to add a RowVersion attribute to an EF4 class

I am using EF4 and creating classes through the Entity design surface then generating the database from them. I want to add an attribute to some of the classes to show the timestamp they were last updated. I have added a Version attribute to them, bu