Tagged Questions
The ADO.NET Entity Framework is a set of ORM (Object-Relational-Mapping) tools for the .NET Framework, since version 3.5 SP1.
2
votes
1answer
14 views
EF6 unit of work pattern with IoC/DI
I'm trying to implement the unit of work pattern with dependency injection / inversion of control and entity framework version 6.1.1, in an asp.net-mvc project.
...
2
votes
1answer
58 views
ComponentManager - Entity-Component-System architecture in C++
Lately I've been working on a small C++ Entity-Component-System framework.
Like most other ECS frameworks the internal data is presented as a table where an entity is a simple row index and each ...
20
votes
2answers
246 views
+100
KISS my… unit of work
I've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity.
Sure the complexity buys you (sometimes) full decoupling ...
3
votes
0answers
70 views
Find the number of Colleges offering Combinations of Levels: Performance
I have been using entity framework 5 as DataAccess layer for my application.
I have a case where there are a set of 'Levels' offered. And I have a set of 'Colleges' offering the 'Levels'.
Class Level:
...
2
votes
2answers
54 views
Database mirroring cache
I generally prefer to work with EF by specifying exactly the data to fetch from the DB with regards to Navigation Properties/Lookups and the like, so we wrote this cache system to limit the number of ...
2
votes
0answers
77 views
Generic Entity Framework Query in CQRS
I've been working on our application (CQRS and DDD) for awhile now. The application architecture is well layered and thought through.
However we are having difficulties in decide where to put the ...
3
votes
0answers
59 views
Updating Related Data the MVC/EF Way
I have an ASP.NET MVC Controller, the relevant parts of which appear here:
...
10
votes
2answers
214 views
Concerns about the correctness of my 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 ...
5
votes
2answers
105 views
1
vote
1answer
63 views
Dynamic Linq from string with EF
I wrote an EF browser to dynamically navigate through entities. Beside basic properties of system types, each entity can have several singular or plural navigation properties. In order to support all ...
1
vote
4answers
92 views
Checking if there are tags or categories in the database
The code below is used to check if there are tags or categories in the database. If they exist, they are not added to the database, otherwise they are added.
Is this code efficient and easy to read?
...
2
votes
1answer
40 views
Can this method be changed to remove all objects in one call?
I am converting a VB.NET app over to C#. I won't subject you to the old code but the following is done in a little over 100 lines using nested loops. I am using Entity Framework 6 as my ORM. I have ...
3
votes
1answer
64 views
Data model for tracking currency in a safe [closed]
I am attempting to design an application that tracks currency and recent transactions in a safe. I am using entity-framework code-first in a wpf desktop application.
The first goal is to be able to ...
2
votes
1answer
98 views
Is there better way to shorten this Lambda expression's result selector?
I'm new in LINQ and Lambda expression. I'm not sure is there a way to shorten the result on this o.z.cust.cust.cust.bintAccountNo. As you can see below, the more ...
10
votes
2answers
269 views
Do I need ninject when implementing DAL with generic repository and unit of work?
I am implementing generic repository and unit of work for the first time. I would be glad if someone can correct me if I am doing something wrong here.
This is how I communicate with my DAL from ...
1
vote
1answer
66 views
Concept for saving context information
My Problem
I have a library containing business logic which is being used from 3 different projects:
Website
Local WPF Application
WCF Service
The library uses Entity Framework and a connection ...
7
votes
4answers
446 views
Basic Entity Framework Repository implementation
Here is simple repository pattern that I use to access data in my database. I would like some advice on how to improve this code. Commenting on my code quality is also welcome too!
...
1
vote
1answer
99 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:
...
3
votes
1answer
79 views
Entity Framework - updating two different arrays of child associations
Exercises have Muscles and Tools. When someone adds or updates an ...
10
votes
1answer
211 views
EF6-Lambda Expressions deep big-tree query
I am looking to improve the following query.
We are using EF6 (CodeFirst) and C# Lambda Expressions, and Repository/Unit of Work patterns. Also, we needed to restrict the query in a way that we ...
2
votes
4answers
370 views
Silent Try_catch in high load socket server or not?
I'm working on a socket application that will listen to incoming messages from about 400 devices. They all send a message at least once per minute. Now I have a working program and it has been running ...
5
votes
1answer
59 views
EF query for calculating monthly trends
My application has a fairly important query that is used in a lot of places. Unfortunately it takes about 14 seconds to run, so I'd like to find a way of possibly improving it.
The application ...
1
vote
1answer
72 views
Refactor Oracle Entity Framework lambda query
I had a ugly problem and wrote an ugly query.
Query creates a cache that is used to get person id when I have {full_name, id_code?, birth_date?}. By question mark I mean that it is perfectly valid ...
5
votes
2answers
262 views
3
votes
1answer
92 views
Method to save child objects
I'm using Entity Framework 6 with database first. See the image for the relevant database schema
I have the following method to save a Set to the database:
...
0
votes
0answers
82 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've a WebApi action method in which I've to update some data in my database based on the request. ...
5
votes
1answer
78 views
Work around for EF6 bug 1748 in the Entity Framework
Entity Framework 6 fails to handle the maintenance of LocalDB's global list of databases. That is noted here: Application fails when attached mdf and ldf files are deleted
Here is my code to work ...
6
votes
1answer
150 views
Refactoring a LINQ query that (sometimes) returns null
I have the following LINQ query that should return a result for each Request. I'd prefer to have the query translated to ...
1
vote
1answer
216 views
Multi threading in ASP.Net to increase performance of processing data from entity framework using anonymous types
Intro
I am trying to populate a Multi-column Combo-box with a large amount of records.Depending on the selection the user has taken there can be 1 - 50000 items in the Combo-box (I may not display ...
4
votes
1answer
83 views
Insert Model object effectively using entity framwork
I have a WPF MVVM Application. I have a Customer Model which is generated by an entity framework (Database first approach) and one CustomerViewModel where I ...
2
votes
1answer
114 views
BaseRepository for EF6 - updated
Previous question: BaseRepository for EF6
I've update my code. Is it correct now? I've changed IEnumerable to IQueryable.
...
8
votes
6answers
385 views
2
votes
1answer
96 views
Making the objectContext.CommandTimeout configurable?
I am trying to make the CommandTimeout value more configurable. I'm wondering if this is best practice to do so?
I add the following to my <appsettings> ...
3
votes
3answers
422 views
Entity Framework with multiple connections open?
I'm learning Entity Framework and I'm wondering if this code is the proper way of doing this. Basically this is my attempt at refactoring a very long controller in ASP.Net MVC 4. I'm using Entity ...
2
votes
1answer
129 views
Seperating Entity Framework into BLL
I have an Entity Framework working with a SQL database. A Web Forms application is currently communicating directly with the Entity Framework model from code behind. I have been tasked with creating a ...
4
votes
1answer
108 views
Saving a sales order - too many repositories?
I am wondering if I have overdone it with repositories in the following code, which is to save a sales order.
I understand that the purpose of a repository is to decouple the domain layer from the ...
2
votes
1answer
72 views
Compare Collection with the information in DB using EF and LINQ
I want to inform the Receivers about new contracts we have this week. After I sent the Emails, the Information about sent contracts are stored in MS SQL Database.
To avoid that someone become the ...
4
votes
1answer
197 views
EntityFramework-based filtering
I am trying to use the following form to enter new info into a database.
I am trying to use the entity framework.
I have the following classes of Interest:
...
2
votes
1answer
272 views
Parent/child relationships: adding/updating details to an answer
Answer is the Parent table and AnswerDetail is the child. Below works, but I'm wondering if there is a better way to do this using EF?
My Method Signature is this:
...
5
votes
2answers
202 views
Getting list of daily team goals
The old code I had before was atrociously slow but after some advice and research I was able to take a 2-5 minutes run time down to about 5-30 seconds. That is acceptable, but still looking to have ...
5
votes
3answers
226 views
Calculating total sales from each member
I am building a new system that is using some tables from an old system.
For each user on this new system, I need to go to the old system and total up their sales. Currently it takes between 2-5 ...
4
votes
1answer
112 views
Am I even using the Entity Frameowrk and/or LINQ the way it is supposed to be used?
I feel like just because the below works doesn't mean it is correct, I want to improve it but I can't really figure out how. Besides the fact it is down right ugly I feel the performance could be ...
8
votes
2answers
4k 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:
...
4
votes
1answer
990 views
Database first entity framework, repository, service, UnitOfWork pattern
I have seperated my project into two projects. One is the web forms project and the other is the Model project with contains a generic repository implementation, a service class for each of my ...
2
votes
2answers
102 views
Add chat to an MVC database: Can I condense this code and is it appropriately placed?
I have these relevant tables in an MVC website:
Server
ServerPlayer
ServerPlayerChat
Servers have serverPlayers, ServerPlayers have ServerPlayerChats. Simple enough and expectable.
I'm using ...
1
vote
1answer
74 views
4
votes
2answers
89 views
Retrieve Tasks by Employee
I think I've done a decent job keeping this query simple and understandable, but I'd like to know if you have some more advice.
My relevant entities are defined like this:
...
7
votes
1answer
970 views
MVC 5 & EF 6 - Repository & Unit of Work Pattern
I have been looking through Code Review on the subject of Unit of Work and Repository patterns and realised that my implementation appears to provide very similar functionality but in reverse class ...
4
votes
1answer
171 views
Using static management class to control db transactions through an EF6
I have the class below to manage my specific implementation of a membership system using entity framework 6.1
Is the use of static access correct in this case? as far as I understood that EF context ...
5
votes
2answers
499 views
Entity Framework Skip and Take too slow
The following code achieves what I require, reading 10000 rows at a time:
var query = repository.Subscribers.ToList().Skip(numberToSkip).Take(numberInBatch);
Is ...