Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have started to doubt my initial design decision, as everywhere I look I find tutorials on MVC where they just dump the access layer right into the MVC project. (Which goes against everything I've learned)
BarRepo: Handles access to an API.
FooRepo: Handles access to my Database (using EF).
FooBarHandler: Joins data from the two repos into useful data for the controller.
Controller: A controller, nothing speical.
As you can see in the picture, I've split up each part into their own project and try to obtain loose coupling. So I don't send Entity Framework classes out of the database layer and so on. However I've run into a bit of a pickle. The data amount fetched have become so large that it's noticeable on the frontend, so I needed to introduce paging. So I followed this tutorial.
My "problem" is that now MVC, Logic and the Database projects are depended on PagedList, so things aren't so neat and shiny anymore.
So my question is what would you have done?
You don't need to use PagedList as you can create a paged list of items yourself. Take a look at this StackOverflow question for an example of how to do this.
To summarise:
var pageNum = 3;
var pageSize = 20;
var pagedItems = data.Skip((pageNum - 1) * pageSize).Take(pageSize).ToList();
That way you will have no dependancies on PagedList, which will help reduce the coupling in your design.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
In either .NET MVC 5 or a .NET Core MVC application, is it possible to split your Models into a Data Transport Layer, your business logic into a Business Logic Layer and your Db Contexts into a Data Access Layer? I essentially would want the main project to really only have controllers that call to the BLL, and display the results in the view. That way there is portability with my application if I wanted to exchange the main project, which is essentially just a presentation layer.
I know I am going to be needing this kind of architecture as I am building an application that will share a lot of the same business logic between the two applications. What ways can I still get access to helpful features like scaffolding a model into views/controller, and still maintain that portability? Is there a way to do such a thing?
Please note, that this project may be on a short budget, so it is pretty essential to be able to maintain the scaffolding tooling.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
In most ASP.NET Mvc tutorials, you see people creating simple models and then scaffolding controllers with views, using Entity Framework.
In most tutorials you will also see that they create a new DbContext class which will have the DbSets. I understand that this is a good thing to do for educational purpose, to help the person understand how it works.
But the account system that comes with a default Mvc project always links to "DefaultConnection".
Some tutorials will also make use of the account system to advance further, but that means that at this point you would have 2 databases running to support your web app.
one for the account info
one for the details of your model(s)
Is this the correct way to work? or do most developers/companies just use 1 database for both of these?
My reason for asking is because i found this tutorial which uses both of these aspects and works on 1 database and it is the first time i see this being done.
There's no right or wrong way. You need to evaluate the requirements and time lines for your projects and decide which options suits you best.From personal experience, in all the projects I worked on, the account info and the models reside on the same database.
Remember that if you have two databases you will need to create two data contexts to access them.If the database needs to be moved to another server, you would need to move two databases and change the connection string in two places, also the maintainance and upkeep on the DB would need to be performed in two different places.It's really a maintainance headache and should be avoided in my opinion unless your requirements have some compelling reason that you should place account info into a separate DB.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I went through the online Falcor videos and tutorials and it sounds very interesting. I am trying to determine if this would be a good fit for our application needs. Somewhere in the presentation I heard that it is very well suited for fairly static application, meaning the data is huge but mostly static. In our case, the data is huge but also gets updated frequently. So, the question how Falcor works when the backend data gets updated frequently.
If data held in client memory becomes stale due to its server-side representation changing (e.g. two separate users manipulating the same part of the graph) then you'll need some sort of server-push-to-client event stream thingy to notify the client of changes so it can keep its data cache fresh.
To my knowledge Falcor doesn't have any built-in hooks for this sort of thing. That doesn't mean Falcor can't be used for dynamic data; most MVC framework have this caveat. Just something to be aware of.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am in confusion about the data access technology in mvc4 whether we should use Entity Framework or Linq or something else which is better than this ?
I have research much in this topic and not satisfied with all.?So can you help me about this with proper Detail?
The question will have answers upon user based opinions and experience.
This is what my personal recommendation is Model:
Take this as a Tree View Structure
1. Controller
2. ActionMethod //call the desired Factories
3.1 View Factory //to get data in DB
3.2 Domain Factory //to set data in DB
4. Services //Interface for Caching and top operations
5. Repositories //Contains on CRUD Operations
Inside the Repositories I would prefer LINQ-to-Entities rather than LINQ-to-SQL.
A great way of UNIT OF WORK PATTERN is being explained here
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
First of all, this is my first week on MVC 4
Microsoft claims the MVC will be the best web coding solution in the future based on three level framework.
1.Yet in their MVC concept, view and model can talk without controller, can any body tell me why they made that like a circle? What's the benefit behind it?
2.Without the view_state in web form, how can I know if a page is a post back?
Any open-mind ideas are welcomed!
1.Yet in their MVC concept, view and model can talk without controller, can any body tell me why they made that like a circle?
What's the benefit behind it?
View and Model cannot talk without controller. Your view would never have known the Model if the Controller hasn't passed it to.
2.Without the view_state in web form, how can I know if a page is a post back?
Why would you even want to know such thing? This is an artificial concept invented specifically for classic WebForms to alleviate the stateless nature of the HTTP protocol and make Web development ressemble Desktop development. In an MVC application you never need to know anything like that.