以下代码中的LINQ是什么?

时间:2015-12-16 00:00:37

标签: asp.net-mvc linq linq-to-sql

 // GET: racunTest/Edit/5
    public ActionResult Edit(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        racun racun = db.racuns.Find(id);
        if (racun == null)
        {
            return HttpNotFound();
        }
        ViewBag.kupac_id = new SelectList(db.kupacs, "id_kupac", "naziv", racun.kupac_id);
        return View(racun);
    }

    // POST: racunTest/Edit/5
    // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
    // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Edit([Bind(Include = "id_racun,dv_racuna,status,dv_placanja,kupac_id")] racun racun)
    {
        if (ModelState.IsValid)
        {
            db.Entry(racun).State = EntityState.Modified;
            db.SaveChanges();
            return RedirectToAction("Index");
        }
        ViewBag.kupac_id = new SelectList(db.kupacs, "id_kupac", "naziv", racun.kupac_id);
        return View(racun);
    }

    // GET: racunTest/Delete/5
    public ActionResult Delete(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        racun racun = db.racuns.Find(id);
        if (racun == null)
        {
            return HttpNotFound();
        }
        return View(racun);
    }

    // POST: racunTest/Delete/5
    [HttpPost, ActionName("Delete")]
    [ValidateAntiForgeryToken]
    public ActionResult DeleteConfirmed(int id)
    {
        racun racun = db.racuns.Find(id);
        db.racuns.Remove(racun);
        db.SaveChanges();
        return RedirectToAction("Index");
    }

这个代码中是否有LINQ?它是什么,或者它都是LINQ。我必须使用LINQ从DB获取简单的数据,但它看起来很难,我甚至不知道应该在哪里,放置LINQ代码,以及如何显示数据? LINQ和LINQ to SQL是一回事吗?

1 个答案:

答案 0 :(得分:1)

您的问题显示完全没有努力调查此事。

LINQ =语言集成查询;它的语言结构允许您以类似于SQL的方式查询对象/数据库/其他。

首先阅读this

等指南