ASP.NET MVC with ADO.NET DataServices - asp.net-mvc

In the project i am working on, i want to use the ADO.NET data services as data access layer. so that other parts of my application (except asp.net mvc web site) could also access it from the same location. I am just not sure if this si the correct model and also for asp.net mvc models I wanted to reuse the data services model, as much as possible and also some how decorate them as required fields etc.
Other option i started looking at was to use RIA services as back end to the MVC site.
I am very confued at the moment and any help would be appriceated.

Have you taken a look into WCF data services?
http://msdn.microsoft.com/en-us/data/bb931106.aspx

Related

What is the difference between MVC in Angular JS and MVC in ASP.NET or Spring MVC?

I'm trying to understand modern web applications architecture. In ASP.NET MVC, all the business logic classes are in Model and Controller takes and guides user requests.If I am using it, is it possible to use Angular JS which itself is a MVC architecture but all the business logic is in controller and model is just POJO.
Can Angular JS be used only with Web API 2 where it gets data from a RESTful service and it does all manipulation on the client side? Which architecture is most commonly used ?
From my perspective, you're confusing two very different technologies; One is server-side (ASP.NET MVC) an one is Client Side (AngularJS).
The two can certainly be used hand-in-hand as neither are dependent on the other existing. And, IIRC, there is a scaffolding module on NuGet that helps bindings from one to the other (Create JS objects from your ASP.NET POCO objects).
With that being said, there is no reason you need to use both. You can one one or ther other, both, or bring in a different technology altogether (KnockoutJS, etc.)?
In ASP.NET MVC, all the business logic classes are in Model and Controller takes and guides user requests
This is not true. Models (a.k.a. ViewModels) should be plain ("POCO") data containers in ASP.NET MVC. Business logic should come from a layer consumed by the controllers, but in smaller applications or before refactoring, the controller is a more appropriate choice than a (View)Model.
Can Angular JS be used only with Web API 2 where it gets data from a RESTful service and it does all manipulation on the client side? Which architecture is most commonly used?
No, you can use ASP.NET MVC with Angular JS as well by returning JsonResults from controller actions. That said, WebAPI is a better / more appropriate choice. Of course you can also use Angular with many other non-Microsoft tools that return JSON over http(s) (for example node, ruby, java, etc).
To more directly answer your actual question, the main difference between the two is that one is an MVC pattern for the server, and the other is an MVC pattern for the browser. Angular actually likes to call it an "MVW" pattern, where the "W" stands for "Whatever".
Like as other design patterns (Singleton, Factory, Factory method) MVC
is also a design pattern that we can use in any technology like(Java,
.net, PHP) or to any client site scripting. there is no difference between MVC in Angular JS and MVC in ASP.NET and Spring MVc

ASP.NET MVC without database INSERTS

I used asp.net web forms before and currently thinking to switch to MVC, the issue is, my current project is against a 'real time database' - PI from OSISoft - where I don't need CRUD operations at all, its a view only application; is the MVC model still applicable here or what?
Sorry for the newbie question.
ASP.NET MVC and Web Forms are web application frameworks. They don't define any constraints on data access. With a little refactoring you should be able to use same data access code (C# or VB) in an MVC application.
Funny, I just created a dashboard for a PI server. Used ASP.Net MVC and Web API to surface the information, it worked a treat.
Note MVC doesn't actually have anything to do with data persistence. It is simply a well-conceived UI design pattern.

Using Sencha's ExtJS MVC with ASP.NET MVC

I wanted to ask if anyone has tried using combination of Sencha's ExtJS 4 (using MVC approach) with ASP.NET MVC (using view models)?
I have existing ASP.NET MVC 3 app that uses view models and my question is how would this "fit" into Sencha's MVC approach...Would ASP.NET MVC "view model" become ExtJS "model" and then I would define yet another "view model" for ExtJS....Seems a lot of "translating"...
What would be the best approach?
And yes, I am aware of projects that integrate ASP.NET MVC with ExtJS using Ext.Direct, but my question is strictly relating to MVC paradigm on "both" sides (ASP.NET and Sencha ExtJS)
Thanks
Z...
Our approach currently is a what could be described as MVCCM or MVC-CM.
In ExtJs you have the view as panels and boxes etc, a store with a model makes a model and you need some logic to make these components work together which would be the controller.
This ExtJs frontend is situated in a MVC3 project and exposes controller methods that typically returns Json data which it gets from the model back end which is typically made up of entities.
There is no programmatic link between the entities on the server side and the models defined in the stores client side. One could generated the stores from entities, but we have not looked into this yet.
The view in the Microsoft MVC3 framework is just a page that returns some div tags which ExtJS can render stuff into.
While I've not done this with ExtJS, I really don't think there's any conflict. I'm assuming a lot here, I know, but if ExtJS works with JSON and you've got ASP.NET MVC actions that emit JSON, it's really more of a philosophic difference than a technical one.
One difference from a normal MVC app would be that your ASP.NET MVC app might not have any views, since the views would be handled entirely by ExtJS.
From the server side, ASP.NET MVC really doesn't care - it's getting a request that gets mapped to a controller and action, processing the request and returning some result. Whether that result is HTML, JSON, XML or whatever, ASP.NET doesn't care at all.

How do you place a web services aside with your ASP.NET MVC web application

I currently have a web application written by ASP.NET MVC. Now I want to add a web service so that some people can easily build application upon it. Shall I just create the asmx in the MVC Web project or create another project referencing to the Model project? And what's the pros and cons?
Thanks in advance!
Easy decision - if your MVC Web project depends on the web service at all, keep it in the MVC Web project. If not, create a separate project for the web service with reference to your model.
Keeping projects seperate allows people to read and understand your code more effectively. If your service makes use of your model, but is not part of that model, than it should definitely be a standalone project with reference to the model. This is clean design.
for my opinion I would do something like this in my solution
solution.Model -- the model that reflects your db,
solution.Repository
solution.MVC -- your model will be the refined Model, referencing the solution.Model
solution.Test
solution.WebService -- referencing solution.Model
I keep my Model outside my MVC Web application and just put the refined ViewModels in my MVC Model folder. I don't know much about pro's and con's but this is just a better way of doing it for me.
Doing this, you can use your Model anyway you want. Maybe you want to use it for WebService as what you ask. Or for another Application. You just reference your Model project to other projects that you need them.
I would look for Odata -> WCF Data Services formaly know as "Astoria".
If you are using for example linq-to-sql or EF you can make your data in a restful manner availale and provide a basic api...
You can define your endpoint like you do in WCF because the underlying service is based on WCF. And I would use a different namespace...
Website
http://msdn.microsoft.com/en-us/data/bb931106.aspx
Beginners guide with videos
http://msdn.microsoft.com/en-us/data/ee720180.aspx
open data format
http://www.odata.org/

ASP.NET MVC + Oracle: samples and how-to

While reading NerdDinner, and browsing other examples on the internet regarding ASP.NET MVC with LINQ To SQL.
In my ASP.NET MVC project I have to connect to an Oracle database. The main goal of the application is to display, edit, and update data. I am uncertain if ASP.NET MVC can work with an Oracle database.
Has anyone ever done an ASP.NET MVC project with Oracle as the database?
Are there any articles with sample code that you'd recommend?
What are some easy ORMs or data access strategies that you'd recommend an ASP.NET (webforms or MVC) project use to communicate to an Oracle database?
You can use Nhibernate to get access to your DB.
ASP.NET MVC can certainly support Oracle or any other data source behind the scenes.
MVC is not tied to Linq to SQL in any way. It's just one convenient way (among many) to get data from a datasource into your models.
As Sly pointed out, NHibernate is one ORM framework that will work for you.

Resources