数据存储在哪里? [英] where is data stored?

查看:213
本文介绍了数据存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mvc3在.net 4.0中设计一个项目。我使用两个属性 name fname (父亲姓名)。

i am designing a project in .net 4.0 using mvc3. I am using two attribute name and fname(father name).

我的控制器类:

loginController.cs

loginController.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcMovie.Models;

namespace MvcMovie.Controllers
{ 
    public class loginController : Controller
    {
        private logindata db = new logindata();

        //
        // GET: /login/

        public ViewResult Index()
        {
            return View(db.loginobj.ToList());
        }

        //
        // GET: /login/Details/5

        public ViewResult Details(int id)
        {
          //  login login = db.loginobj.Find(id);
            login login = db.loginobj.Find(2) ;
            return View(login);
        }

        //
        // GET: /login/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /login/Create

        [HttpPost]
        public ActionResult Create(login login)
        {
            if (ModelState.IsValid)
            {
                db.loginobj.Add(login);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }

            return View(login);
        }

        //
        // GET: /login/Edit/5

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}

模型类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
login.cs

namespace MvcMovie.Models
{
    public class login
    {
        public int ID { get; set; }
        public string name{get; set;}
        public string fname { get; set; }
    }
    public class logindata : DbContext
    {
        public DbSet<login> loginobj { get; set; }
    }
}

view.cshtml

view.cshtml

@model IEnumerable<MvcMovie.Models.login>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            name
        </th>
        <th>
            fname
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.fname)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
    </tr>
}

</table>

我想知道我创建的数据存储在哪里?意味着我如何看到由我做的条目表?

I want to ask that where is data stored which is created by me? means how can I see that table of entries which is done by me?

每当我点击.sdf文件,然后有一个问题发生,如下图所示,什么应该我做解决这个问题。应该我安装的东西。我安装了visual studio 2010和sql server 2008.

whenever i click of .sdf file then there is a problem occured as shown in following picture, what should i do to solve this problem. should i installed something. i installed visual studio 2010 and sql server 2008.

推荐答案

可能你正在使用Microsoft SQL CE来存储你的应用程序数据。如果是这种情况,请查看解决方案资源管理器中的App_Data文件夹。你应该看到一个.sdf扩展名的文件。只需确保在解决方案资源管理器中选择显示所有文件图标。更多详情这里

Probably you're using Microsoft SQL CE to store your application data. If this is the case, take a look at the App_Data folder in Solution Explorer. You should see a file with .sdf extension there. Just make sure to select Show All Files icon in Solution Explorer. More details here.

这篇关于数据存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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