Explain the architecture and design principles of .NET. Create methods to insert, update, delete and read all data for the table Student having following fields StudentId(int), Name varchar(200), RollNo (int), Class varchar(50) using Entity Framework.

 

NET is tiered, modular, and hierarchal. Each tier of the .NET Framework is a layer of abstraction. .NET languages are the top tier and the most abstracted level. The common language runtime is the bottom tier, the least abstracted, and closest to the native environment. This is important since the common language runtime works closely with the operating environment to manage .NET applications. The .NET Framework is partitioned into modules, each with its own distinct responsibility. Finally, since higher tiers request services only from the lower tiers, .NET is hierarchal. The architectural layout of the .NET Framework is given below.





            Figure: An overview of the .NET architecture.


Common Language Runtime (CLR) is the heart of the .Net Framework. It resides above the operating system and handles all .Net applications. It handles garbage collection, Code Access Security (CAS), etc.

Common Language Infrastructure (CLI) provides a language-independent platform for app development and its performance. It also includes the function for exception handling, waste collection, security, etc.

Common Type System(CTS) specifies a standard that represents what type of data and value can be defined and managed in computer memory at runtime. For example, in C# we define data type as int, while in VB.NET we define an integer as a data type.

Common Language Specification(CLS)  is a subset of a common type system (CTS) that defines a set of rules and regulations which should be followed by every language that comes under the .net framework. For example, in C# and VB.NET language, the C# language terminates each statement with a semicolon, whereas in VB.NET it does not end with a semicolon, and when these statements execute in .NET Framework, it provides a common platform to interact and share information with each other.

FCL (Framework Class Library) provides the various system functionality in the .NET Framework, which includes classes, interfaces and data types, etc. to create multiple functions and different types of applications such as desktop, web, mobile application, etc.

Design principles of .NET:

  • Interoperability
  • Portability
  • In-built security mechanism
  • Robust memory management
  • Simplified deployment
  • Asynchronous Programming
  • High Performance


Second Part


namespace CSharpExamples

{

    class EFCoreTest

    {

        private StudentContext _context = new StudentContext();

        public List<Student> GetAll()

        {

            return _context.tblStudent.ToList();

        }

        public void InsertStudent(Student emp)

        {

            _context.Add(emp);

            _context.SaveChanges();

        }

        public int EditStudent(Student emp)

        {

            if (emp.StudentId == -1)

            {

                return 0;

            }

            var stud = _context.tblStudent.Find(emp.StudentId);

            if (stud == null)

            {

                return 0;

            }

            int updatedCount = 0;

            try

            {

               _context.Update(stud);

               updatedCount = _context.SaveChanges();

            }

            catch (DbUpdateConcurrencyException)

            {

                return 0;

            }

            return updatedCount;

        }

        public int deleteStudent(int StudentId)

        {

            if (StudentId == -1)

            {

                return 0;

            }

            var stud = _context.tblStudent

                .FirstOrDefault(m => m.StudentId == StudentId);

            if (stud == null)

            {

                return 0;

            }

            _context.tblStudent.Remove(stud);

            int updatedCount =  _context.SaveChanges();

            return updatedCount;

        }

        public void showStudents(List<Student> students)

        {

            foreach (Student student in students)

            {

                Console.WriteLine("Student ID = " + student.StudentId);

                Console.WriteLine("Student Name = " + student.Name);

                Console.WriteLine("Student RollNo = " + student.RollNo);

                Console.WriteLine("Student Class = " + student.Class);

            }

        }

}

Class Program

    {

        static void Main(string[] args)

        {      

            EFCoreTest test = new EFCoreTest();

//Read All Students

            List<Employee> employees = test.GetAll();

            Console.WriteLine("Initial Records");

            test.showStudents(employees);

            //Insert Student

            Employee stud = new Employee();

            stud.Name = "Ram";

            stud.RollNo = 31;

stud.Class = "Sixth Sem";

            test.InsertStudent(stud);

            Console.WriteLine("After Insert");

            test.showStudents(employees);

            //Update Student

            stud.Name = "UpdatedName";

            test.EditStudent(stud);

            Console.WriteLine("After Update");

            test.showStudents(employees);

            //Delete Student

            test.deleteStudent(stud.EmployeeId);

            Console.WriteLine("After Delete");

            test.showStudents(employees);

            Console.ReadLine();

        }

    } 

}

Comments

Popular posts from this blog

Suppose that a data warehouse for Big-University consists of the following four dimensions: student, course, semester, and instructor, and two measures count and avg_grade. When at the lowest conceptual level (e.g., for a given student, course, semester, and instructor combination), the avg_grade measure stores the actual course grade of the student. At higher conceptual levels, avg_grade stores the average grade for the given combination. a) Draw a snowflake schema diagram for the data warehouse. b) Starting with the base cuboid [student, course, semester, instructor], what specific OLAP operations (e.g., roll-up from semester to year) should one perform in order to list the average grade of CS courses for each BigUniversity student. c) If each dimension has five levels (including all), such as “student < major < status < university < all”, how many cuboids will this cube contain (including the base and apex cuboids)?

Suppose that a data warehouse consists of the four dimensions; date, spectator, location, and game, and the two measures, count and charge, where charge is the fee that a spectator pays when watching a game on a given date. Spectators may be students, adults, or seniors, with each category having its own charge rate. a) Draw a star schema diagram for the data b) Starting with the base cuboid [date; spectator; location; game], what specific OLAP operations should perform in order to list the total charge paid by student spectators at GM Place in 2004?

Discuss classification or taxonomy of virtualization at different levels.