国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

I always feel that asp.net MVC is awkward to write. Compared with PHP's mvc, asp.net is a lot more troublesome?
漂亮男人
漂亮男人 2017-05-16 17:06:17
0
3
735

Does anyone feel the same way?

How to write mvc?

I find it very difficult to write

PHP:

M:
class Teacher {
  function add($data) {
    $sql = "insert into teacher_table($teacher_name) values($data['teacher_name'])";
    return $db->query($sql);
  }
}

V:
(省略)

C:
class Teacher {
  $data = array("teacher_name"=>$_POST["teacher_name"],....);
  $row = new Teacher();
  $row->add($data);
  echo "Yeah~!";
}

asp.net does not have an array as flexible as PHP. Data exchanges between m-v-c are all passed through arrays. Asp.net can't have a hashtable, right? It seems that the tutorials all write entity classes

漂亮男人
漂亮男人

reply all(3)
劉奇

I have never written PHP, but I have experience in ASP.NET MVC development. Here I will briefly explain my understanding.
First, let’s look at an interaction principle of ASP.NET MVC through a picture:

The Model layer is actually a big concept, including services, business logic, data persistence, etc.; the Controller layer plays a role in connecting the Model layer and the View layer; the View layer is the interface, which should be very important. clear.
From your description of the problem, the more tangled point is that when the Controller layer and the View layer interact, ASP.NET MVC uses the method of defining entity classes (ViewModel), which makes you feel that the development method of ASP.NET MVC is very complicated. Effortless.
In fact, this question is relative. First of all, for ASP.NET MVC, basically every view must define a ViewModel. This is indeed a very boring place, but in retrospect it brings benefits: Cooperating with Visual Studio, you can use smart prompts in the view (I won’t expand on smart prompts here, everyone who has used them says it’s good)! In this way, you can avoid the magic string problem in the PHP array $data['xxx'] (for example, you should write $data['teacher'], but accidentally write the wrong $data['teach'], which brings more It's possible to make mistakes, don't you think writing these strings is also a boring thing?).
If you think the array method is better, you can actually do it in ASP.NET MVC. You can use TempData in the Controller class, for example:

public ActionResult List()
{
    TempData["hello"] = "world";
    return View();
}

In this way, the view layer can also obtain data through TempData[].

洪濤

In .Net, your $data can be described by the type Dictionary<string, string> or Dictionary<string, object>.
It's not convenient at all. There are no auto-complete prompts and no static checks in the IDE.

世界只因有你

I have been using it for a long timeasp.net mvc,現(xiàn)在用phpyii,兩者幾乎完全一樣的思想。所以不是說框架哪個更方便,而是語言哪個更方便。我個人也覺得php確實比C#要方便很多,就像你說的,數(shù)組靈活,json靈活,.net現(xiàn)在也有dynamic類型,但是不感冒,感覺生硬。另外一個拋棄微軟的理由就是覺得太麻煩,太封閉,就是不愿意用windows,干嘛要用宇宙第一IDE(visual studio)?老子就是只愿意在linux下用vim, nothing else.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template