The ADO.NET Entity Framework is a set of ORM (Object-Relational-Mapping) tools for the .NET Framework, since version 3.5 SP1.

learn more… | top users | synonyms

2
votes
1answer
67 views

Publishing and removing database tables

I have a switch statement that works just fine, however, it has a lot of duplicate logic within it. I have an enum that my controllers use to say which is making the publish request, so ...
3
votes
1answer
62 views

N-tiered web app to save a role

My project manager is saying that there are many bad things in my code, but they are not helping me to correct it. Can you please specify the bad things they mean? I have 7 projects in my solution ...
3
votes
3answers
7k views

Update multiple records with Entity Framwork

I am wondering what the best way to update multiple records with Entity Framework is. This is how I normally do it, and it does work: ...
2
votes
1answer
99 views

Logic for changing entity navigational properties States

The question might seem a little bit long, but I will be very glad if you have read it till the end and told me your opinions. Let's say I have such entity: ...
2
votes
2answers
91 views

Delayed Include rules for EntityTypeConfiguration using LINQ expressions

The aim of this class is to set rules for including navigational properties on Configuration level and then apply where needed in the code. I've decided to store expressions in the list for different ...
2
votes
1answer
177 views

Restricting search to a user's own department, if the user is not a manager

I hate having almost two identical blocks do almost the exact same thing. I am working with Entity Framework 4.4.0.0 Asp.Net MVC Right now if the user is a "manager" I want to show them the entire ...
0
votes
0answers
89 views

Generic method to pass lambda expressions performed on DTO's to Entity Framework

The following are generic methods that I use to perform lambda queries on DTO objects. The main method applies the expression to entities and returns DTO objects mapped from the entities (entities ...
6
votes
1answer
124 views

Allowing query handlers to use other query handlers

I recently started looking into CQRS when using Entity Framework and the impact it has had on my systems has been overwhelming. I implemented the following patterns described in these blog posts: ...
1
vote
1answer
64 views

Listing users in Azure Active Directory

The code below is the Index Action from a User Controllers. Basically this code returns a list of users from Azure Active Directory using Azure Authentication Library (ADAL). However I need to show ...
18
votes
2answers
34k views

Unit of Work and Repository with Entity Framework 6

Based on the reply of this question I have created the following code. I need to check whether it's good or not. Here is my entity class: ...
2
votes
1answer
99 views

Returning IQueryable<T> from my repository in Repository pattern design pattern

I am developing an application based on Repository design pattern. What should be the return type from the Repository? This is my UserRepository class: ...
5
votes
2answers
220 views

Web API using Repository / UnitOfWork

I'm looking for feedback on a repository I set up based on a blog post I read here. I have just recently got more into .NET within the past year, so any feedback and/or best practices that can be ...
2
votes
1answer
31 views

Cross-Database Query Without Casting to List

I am trying to do a cross-database query without having to enumerate the variable t. ...
1
vote
1answer
45 views

Cross-cutting delete flag in a repository

I want to have a cross-cutting delete flag in my repository. I have the following repository pattern at the moment: ...
0
votes
0answers
47 views

Optimizing LINQ routines

I run a build system. Datawise the simplified description would be that I have Configurations and each config has 0..n Builds. Now builds produce artifacts and some of these are stored on server. ...
2
votes
2answers
213 views

Adding chat to an MVC database

I have these relevant tables in an MVC website: Server ServerPlayer ServerPlayerChat ...
1
vote
0answers
197 views

WebApi synchronize database (EF 6) access

I'm working on an ASP.Net MVC 5/WebApi 2 project. I'm using EF 6 code first for my database access. I have a WebApi action method in which I've to update some data in my database based on the ...
4
votes
1answer
809 views

Generic Repository, UnitOfWork and IOC container

I am stuck to define a generic repository with AutoFac IOC container. I am keeping thing very simple and only showing relevant information. BaseEntity ...
5
votes
4answers
171 views

Generic Repository For Web Apps

I was developing a web app using Entity Framework 6 and MVC 5. For the data access layer, I eased the job and wrote a generic repository as following: ...
18
votes
7answers
48k views

Dynamic filtering and sorting with Entity Framework

I'm developing an application using ASP.NET MVC 3 and Entity Framework 4.1. In that application I have a lot of paged lists. Users can filter and sort these lists. This results in code like the one ...
1
vote
1answer
1k views

Creating models manually in MVC

I am creating my models manually. I have five tables in my database as follows: Members MemberTypeMasters ...
3
votes
2answers
83 views

Linq to entities query for donor registrations [closed]

I'm using Linq-to-Entities for querying, and MVC.NET and C# for coding. I'm trying to generate monthly donor registry report which needs donor count, donors who signed through web,donors who ...
2
votes
1answer
64 views

Thread-safe database updates

I have the following method that will return VariantID for given VariantName ("Name" in db). To avoid calling my db few thousand times I have dumped all records (~30) to the simple dictionary. I'm ...
11
votes
2answers
298 views

Repository and Controller tests

Lately I have been researching how to best unit test an EF repository and given a properly tested repository, what to test in the controller. My research did not reveal many sound examples or ...
6
votes
2answers
139 views

Repository implementation

I have a repository called PostsRepository: ...
2
votes
0answers
37 views

DataDictionary Application - Controller

This is related to DataDictionary Application - Model I haven't done much on the controllers yet, as it's the first time I've written Controller-type classes and wanted some quick feedback on really ...
1
vote
1answer
119 views

Table join using the repository pattern

I am new to repository pattern. If I want to join two tables, where should I implement the logic? I have implemented it as shown below. Is there any better way to achieve the same? This is my ...
2
votes
1answer
59 views

DataDictionary Application - Model

Following on from my previous question, I think my Entity Framework model code is now complete. First I'll provide a quick overview of the program - everything above the next horizontal rule can be ...
2
votes
2answers
3k views

Making a property virtual to cause EF to load the property

I am walking through a sample MVC4 ASP.NET tutorial available on PluralSight.com, by Scott Allen. I am in a section #5, Working with Data (part 2), "Listing Reviews". This application has a database ...
2
votes
1answer
114 views

MVC Repository Insert Using async

This is practically my first time using async in my code. I read about dos-and-donts but I wanted to get some feedback on what I've written. I'm using a repository ...
2
votes
1answer
59 views

Query the context or resulting list

I was just getting some products using entity framework and was wondering which would be better to do when getting the results, or if there is no difference. Option 1 - Query the context directly ...
1
vote
1answer
54 views

Converting table data into nested JSON

I'm new to C# (coming from a JavaScript background) and it seems like this code could be greatly improved. This SQL query: ...
2
votes
1answer
55 views

Organising structurally very similar classes

A little background - these are classes I've written on top of an Entity Framework model that represents tables on Sql Server with the following names: ...
2
votes
1answer
142 views

Models in .NET: separate settings [closed]

For my models for a certain section I thought it would be better to have a base class model for both "view" and "edit" models, like so: ...
0
votes
1answer
67 views

Awkward Generic Repository Call [closed]

I am implementing a generic repository pattern. I have done this quite a few times now but every time I do it there is something bugging me. If I have a database design like below. (All the tables ...
1
vote
1answer
91 views

LINQ to Entities query of tests for my classes, with many subqueries

This MVC4 controller method, which uses EF6, is taking a long time to run (over 2 seconds). I've added verbose comments for the purpose of this post only. ...
4
votes
2answers
142 views

Two functions to impose order on queries

I am writing a c# program to build generic sort algorithm on a request to a collection of data. The data needs to be sorted based on the supplied columns.I am using Entity framework and Expression ...
1
vote
0answers
252 views

Entity Framework 6.0.2 - Performance of Auditable Change Tracking Part 2 of 2

This is Part 2 of a question about performance and general best practices. Part 1 is located here. The body of the messages are the same to illustrate their similarity, the difference is the code ...
3
votes
1answer
933 views

Entity Framework 6.0.2 - Performance of Auditable Change Tracking Part 1 of 2

This is Part 1 of a question about performance and general best practices. Part 2 is located here. The body of the messages are the same to illustrate their similarity, the difference is the code ...
6
votes
2answers
247 views

EF lookups and enums

I have a lookup table "RequestTypes" that has the following data: ...
1
vote
0answers
281 views

Retrieving Primary Key from Entity Framework entity

Entity Framework (version 6) generates classes based on your tables that look like this (where each property represents a field in the table): ...
1
vote
0answers
36 views

Query against history table

I have this linq query that queries a table that retains any change history done to any of the tables is constructed like this: ...
5
votes
1answer
296 views

MergeUtility for Entity Framework

Here is a utility that supports ETL/merging in Entity Framework. If it's not appealing as a general purpose tool, why? If it is appealing as a general purpose tool, how might the design be made ...
7
votes
1answer
283 views

Comparison table for comparing products

I'm attempting to create a comparison table to compare products depending on the add-ons they have. To grab the data and filter it I'm using LINQ To SQL. Table's Layout (cut short): ...
5
votes
2answers
166 views

Exporting site and address data

These two methods do very similar things. Is it possible to condense these somehow? This is using the Entity Framework. ...
3
votes
1answer
203 views

Improving LINQ expression with inner method call and switch statement

I have the following class which returns an expression that then returns data. It seems a tad over complicated and I'm pretty sure LINQ has something to offer that makes my life much easier. But I ...
2
votes
2answers
105 views

MVC4 Unit Of Work with Entity FrameWork

I am designing a new asp.net MVC4 application. I know that context class generated by EF is Unit of work and Dbset is the repository class. I am just avoiding the extra abstraction. I want to know ...
1
vote
1answer
54 views

Exposing includes to client over webservice for database queries

I am using a CQRS type patter for querying data in my application. I am currently using entity framework to connect to the database. ...
12
votes
3answers
15k views

MVC Layered Project Structure

We are starting a new web project using C# / MVC4 and Entity Framework 5 for data access. I've decided to go with an n-layered approach for the structure of the project and I would like some feedback ...