Friday 4 August 2017

How to write code in EntityLayer in ASP.Net?

For inserting data or create data records into the database , firstly we have to create database and tables , after that we have to design ASP.Net webforms for providing Interface.
Here we are using StudentRegistration table of Example database , in which
RegistrationID is the primaryKey
FirstName is type of  nvarchar(max)
Lastname is type of  nvarchar(max)
UserName is type of  nvarchar(max)
Password is type of  nvarchar(max)
Email is type of  nvarchar(max)
MobileNumber is type of  nvarchar(max)
GenderID is type of  int
DOB is type of Datetime..

So firstly we need to define properties into our application  so we use Entity Layer ....
So right click on Project and ADD a Folder called App_Code..

In App_Code add a folders called EntityLayer .
Right click on EntityLayer and add a class named studentregistration_BEL and paste the code below.




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

public class studentregistration_BEL
{
    public studentregistration_BEL()
    {
        //
        // TODO: Add constructor logic here
        //
    }
//Use can delete it.It is constructor mainly used for initializing the data members of any class.

    private int _registrationid;
    private int _genderid;
    private DateTime _dob;
    private string _firstname;
    private string _lastname;
    private string _username;
    private string _password;
    private string _email;
    private string _mobile;
    public int RegistrationID
    {
        get { return _registrationid; }
        set { _registrationid = value; }
    }
    public int GenderID
    {
        get { return _genderid; }
        set { _genderid = value; }
    }
    public DateTime DOB
    {
        get { return _dob; }
        set { _dob = value; }
    }
    public string FirstName
    {
        get { return _firstname; }
        set { _firstname = value;
        }
    }
    public string LastName
    {
        get { return _lastname; }
        set
        {
            _lastname = value;
        }
    }
    public string UserName
    {
        get { return _username; }
        set
        {
            _username = value;
        }
    }
    public string Password
    {
        get { return _password; }
        set
        {
            _password = value;
        }
    }
    public string Email
    {
        get { return _email; }
        set
        {
            _email = value;
        }
    }
    public string Mobile
    {
        get { return _mobile; }
        set
        {
            _mobile = value;
        }
    }


}




No comments:

Post a Comment

Creating First WEB API Project from scratch ?

  For creating Web API project open your Visual Studio Editor and Create New Project as shown in below figure. Now you have to select  ASP.N...