Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my view code is:-
XML
@model MvcApplication6.Models.schooldetails
@{
    ViewBag.Title = "Home Page";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@Model.StudentName</h1>
                <h2>@ViewBag.Message</h2>
            </hgroup>
            <p>
                To learn more about ASP.NET MVC visit
                <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
                The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET MVC.
                If you have any questions about ASP.NET MVC visit
                <a href="http://forums.asp.net/1146.aspx/1?MVC" title="ASP.NET MVC Forum">our forums</a>.
            </p>
        </div>
    </section>
}
<h3>We suggest the following:</h3>
<ol class="round">
    <li class="one">
        <h5>Getting Started</h5>
        ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
        enables a clean separation of concerns and that gives you full control over markup
        for enjoyable, agile development. ASP.NET MVC includes many features that enable
        fast, TDD-friendly development for creating sophisticated applications that use
        the latest web standards.
        <a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
    </li>

    <li class="two">
        <h5>Add NuGet packages and jump-start your coding</h5>
        NuGet makes it easy to install and update free libraries and tools.
        <a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
    </li>

    <li class="three">
        <h5>Find Web Hosting</h5>
        You can easily find a web hosting company that offers the right mix of features
        and price for your applications.
        <a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
    </li>
</ol>



my model code is:-

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

namespace MvcApplication6.Models
{
    public class schooldetails
    {
        public int StudentId { get; set; }
        public string StudentName { get; set; }
        public int StandardId { get; set; }
        public int RowVertion { get; set; }
        public string StandaradName { get; set; }
        public string Description { get; set; }

    }
}


my control code is:-

C#
sing MvcApplication6.Data;
using MvcApplication6.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace MvcApplication6.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var schooldetailsViewModel = new schooldetails();
            using (School1DBEntities contex=new School1DBEntities())
            {
                
                var studentListorderbyFirstname = contex.Students.OrderByDescending(a => a.StudentId);
                var studentfirstOrDefault= contex.Students.FirstOrDefault();
                var joinresult = (from a in contex.Students join b in contex.Standards on a.StudentId equals 
                                      b.StandardId select new { a.StudentName, b.Description });
                var topfive = (from a in contex.Students select a).Take(5);
                var topthree = (from a in contex.Students select a).Take(3);
                var three_join_result = from stdid in contex.Students
                             join stand in contex.Standards on stdid.StudentId equals stand.StandardId
                             join teach in contex.Teachers on stdid.StudentId equals teach.TeacherId
                             //where stdid.StudentId == 1
                             select new { studentId = stdid.StudentId,StandardName=stand.StandardName ,
                                 TeacherName = teach.TeacherName, TeacherType = teach.TeacherType };
                var groupresult = from stud in contex.Students
                                  group stud by stud.StudentId into studentt
                                  select new { StudentName = studentt.Key, StandardId = studentt.Key };



                schooldetailsViewModel.StudentName = studentfirstOrDefault.StudentName;
                schooldetailsViewModel.StudentId = studentfirstOrDefault.StudentId;
            }
           
         
                
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            return View(schooldetailsViewModel);
        }
Posted
Updated 29-Apr-15 22:13pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900