我可以使用纯SQL在ASP.net MVC? [英] Can I use pure SQL in ASP.net MVC?

查看:113
本文介绍了我可以使用纯SQL在ASP.net MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好球员,我需要用纯SQL查询我的数据库项目
同时我想用ASP.net MVC这样我就可以学一门新技术!
我可以使用与ASP.net MVC SQL使用无LINQ to SQL的?!
我还在学习,所以我很抱歉,如果它这么笨使用的东西OLD SCHOOL
但我的教练坚持说,他希望看到一个纯粹的SQL查询

hello guys i need to use pure SQL queries for my database project at the same time i wanna use ASP.net MVC so i can learn a new technology !!! can i use SQL with ASP.net MVC WITHOUT using " LINQ to SQL " ?! i'm still learning so i'm sorry if it so stupid using things the OLD SCHOOL but my instructor insists that he want to see a PURE SQL Queries

推荐答案

是的。你可以使用任何你想为你的模型层。请注意,您可以使用原始的SQL查询使用LINQ to SQL的为好。

Yes. You can use whatever you want for your model layer. Note, you can use raw SQL queries with LINQ To SQL as well.

Northwnd db = new Northwnd(@"c:\northwnd.mdf");
IEnumerable<Customer> results = db.ExecuteQuery<Customer>
(@"SELECT c1.custid as CustomerID, c2.custName as ContactName
    FROM customer1 as c1, customer2 as c2
    WHERE c1.custid = c2.custid"
);

或者,也许你的老师希望直线上升ADO.NET,这太正常工作。
有一个<一个href=\"http://www.java2s.com/$c$c/CSharp/Database-ADO.net/illustrateshowtoperformaSELECTstatementusingADONET.htm\">example这里。

这篇关于我可以使用纯SQL在ASP.net MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆