שינוי בסיס הנתונים לעבודה עם המודל

 

 

הסרטון

 

 

הקוד לדוגמא

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ErezWeb
{
    public partial class home : System.Web.UI.Page
    {
        dbEntities1 db = new dbEntities1();

        public String getUserRecord(int id)
        {
            String res = "";
            user x = (from s in db.user where s.id == id select s).FirstOrDefault();
            res += x.name;
            res += " ";
            res += x.pass;
            res += " ";
            res += x.date;

            return res;
        }

        public void getAllUser()
        {
            var tmp = (from s in db.user select s).ToList();

            foreach (user x in tmp)
            {
                Response.Write(x.id + " ");
                Response.Write(x.name + " ");
                Response.Write(x.pass + " ");
                Response.Write(x.date + "<br /> ");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="home.aspx.cs" Inherits="ErezWeb.home" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="ErezWeb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <%
        getAllUser();
        
        
        
     %>


</body>
</html>