The ADO.NET Entity Framework is a set of ORM (Object-Relational-Mapping) tools for the .NET Framework, since version 3.5 SP1.
0
votes
0answers
24 views
Entity framework context is not refreshing on modification [migrated]
I have a WPF Project which is n-tier architecture and I use context per/call as it has ...
1
vote
1answer
30 views
View Model Constructor Arguments
I have created a ViewModel for a Product Edit page because it has specific related entities I need to load - the class currently looks like this:
...
-3
votes
0answers
28 views
The entity type documents is not part of the model for the current context [closed]
I am using EF6, MVC 5 and UnitOfWork with code first from an existing database. I can query using unitofwork and my repository but when I try to insert into the database, I get
"The entity type ...
-1
votes
0answers
27 views
Syslog application, write to database [closed]
I've written a simple syslog application. It saves logs to a CSV and/or pushes the log to a SQL database. The parameterisation of the method isn't ideal, I don't think.
first up my syslog class, for ...
0
votes
0answers
9 views
Where to put classes for Store Procedures in MVC
I'm using a ASP.NET MVC 5 with Entity Framework 6. I have to use a legacy database and get information from a store procedure which makes calculations and then fill a field in a view.
For that I had ...
0
votes
2answers
29 views
Entity Framework 7 In Memory Database - Unit Testing using xUnit
I'm using EF7 with In-Memory database and xUnit for repository testing. I'd like to know if it's a good practice initializing the database in this manner for reuse it in every test method, ...
0
votes
2answers
56 views
2
votes
0answers
41 views
Unit of work with Repository pattern
I am trying to work on a WPF application and decided to go for Unit of Work and Repository pattern, along with MVVM. I am using Entity Framework as my ORM. Could ...
0
votes
0answers
38 views
Unit of Work by using Windsor Castle
I want to implement Unit of Work patter with the usage of Windsor Castle in order to controll the trasanctions and sessions. What I did till now is:
My business class methods:
...
2
votes
0answers
25 views
Extracting SoftDelete from DbContext
I have a DbContext with a SoftDelete implementation inside it. To make it more clear and maintainable, I wanted to extract it to ...
3
votes
3answers
90 views
Master detail INSERT in Entity Framework 6 Database First MVC 5
I have a DB with a master table called "facturas" and another detail table "facturas_detalle." I would like to insert to them, so this is a "Database-First".
I need some guidance or advise of best ...
1
vote
0answers
29 views
Update Virtual Property in a Code First Model using Independent Association in Entity Framework 6
I have a Model that looks like this:
...
2
votes
1answer
43 views
Resolve entity behaviour based on enumeration type
The core of this question is removing a Static Class smell from my Web-Api/MVC solution. It presently works but feels kind of dirty.
Present Solution
Standard solution with 6 projects:
MVC
Api
...
-3
votes
1answer
66 views
Which way is better (matching Onion Architecture in MVC pattern) for using Provider?
In onion arch. we have multi layer structre:
UI (User interface).
BL (Business Logic / Services).
RE (Repositories).
UI uses BL to get data from RE with some conditions, my question is which is ...
3
votes
1answer
96 views
Run stored procedure from repository using EF
I need to dynamically call a stored procedures from my repository, and here is a my implementation:
...
3
votes
1answer
294 views
EF Generic Repository + Unit of Work pattern with support for Async
I'm working on a generic repository using EF 6 code first and trying to following the Unit of Work pattern. Unity is being used to inject my repositories, and I'm trying to get everything supporting ...
3
votes
1answer
177 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 ...
0
votes
0answers
169 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 ...
2
votes
1answer
84 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 ...
1
vote
1answer
174 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 ...
2
votes
1answer
35 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
51 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
2answers
106 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
143 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 ...
5
votes
4answers
197 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:
...
2
votes
1answer
83 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 ...
3
votes
2answers
85 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
141 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:
...
1
vote
1answer
375 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
0answers
40 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 ...
2
votes
1answer
83 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
1answer
246 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 ...
1
vote
1answer
100 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:
...
0
votes
1answer
68 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 ...
4
votes
2answers
176 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 ...
6
votes
2answers
310 views
1
vote
0answers
616 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
40 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:
...
2
votes
1answer
123 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:
...
1
vote
2answers
126 views
Code separation in MVC
Firstly I am not a professional programmer and I am just learning C#, MVC and Web Development.
Much of what I describe here is self taught and comes from lots of googling and posts on Stack Overflow. ...
7
votes
1answer
149 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:
...
2
votes
1answer
63 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
3answers
184 views
Dealing with DB Through EF within Winforms
I have the following code which uses EntityFramework to reach out to a DB and retrieve data to populate into a Winform application gridview.
I am still quite new ...
2
votes
1answer
106 views
Replacing IUnitOfWork with a Factory Pattern
As a follow-up to this blog post and this question, I wanted to post my idea of replacing the IUnitOfWork with a factory pattern. It seems to me that in the case of this blog post the IUnitOfWork ...
6
votes
2answers
321 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
2answers
131 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
56 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.
...
1
vote
1answer
108 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.
...
2
votes
1answer
627 views
Adding data to the DB in EF without using navigation properties
Questions:
Is there a better way other than assigning IDs manually and creating separate lists for each model the way I have? (for this particular scenario).
If so, how? (Still taking the conditions ...