sonal malhotra

sonal malhotra

  • NA
  • 410
  • 52.3k

it does not display output well n pls fix my query with ef

Jan 3 2019 1:18 AM
 hello ,
 
 
i had made two table as below 
SELECT TOP 1000 [id]
,[Datetpublish]
,[statusid]
,[Title]
,[Author]
,[Content1]
FROM [blogstatus].[dbo].[Blogstatus]
SELECT TOP 1000 [statusid]
,[blogstatusname]
FROM [blogstatus].[dbo].[statusname]
 
 
 in Index controller page
 
 
using (ctx = new blogstatusEntities1())
{
var publish = (from d in ctx.Blogstatus
join m in ctx.statusnames on d.statusid equals m.statusid
where m.statusid == 1
select new
{
id = d.id,
Datetpublish = d.Datetpublish,
Title = d.Title,
Author = d.Author,
Content1 = d.Content1
}).ToList();
return View(publish);
}
 
in view page
 
@using blogwithstatus.Models
@{
ViewBag.Title = "Index";
}
<h2> Blog news</h2>
<h6> list of blog</h6>
@using (var ctx = new blogstatusEntities1())
{
foreach (var blog in ctx.Blogstatus)
{
<div class="panel panel-body ">
<h3>
@blog.Title
</h3>
Author| @blog.Author
</div>
  have u check my query in controller ? and i did wrong any query? please fix these query with ef
   
 
 
 
 
 

Answers (4)