Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc Linq查询从数据库返回sql而不是数据_Asp.net Mvc - Fatal编程技术网

Asp.net mvc Linq查询从数据库返回sql而不是数据

Asp.net mvc Linq查询从数据库返回sql而不是数据,asp.net-mvc,Asp.net Mvc,我不确定问题出在哪里,但我似乎无法让我的程序显示正确的信息。我的应用程序的要求是采用pdf格式,并使用数据库中的信息填充表单字段。问题在于它不会从数据库返回信息,而是返回实体框架生成的sql (text) SELECT [Extent1].[Applicant_ID] AS [Applicant_ID] FROM [dbo].[W4] AS [Extent1] 这是pdf文本框中显示的内容 这是我的问题 public class Query { ApplicatoinContext

我不确定问题出在哪里,但我似乎无法让我的程序显示正确的信息。我的应用程序的要求是采用pdf格式,并使用数据库中的信息填充表单字段。问题在于它不会从数据库返回信息,而是返回实体框架生成的sql

(text) SELECT 
[Extent1].[Applicant_ID] AS [Applicant_ID] 
FROM [dbo].[W4] AS [Extent1]
这是pdf文本框中显示的内容

这是我的问题

public class Query
{
    ApplicatoinContext context = new ApplicatoinContext();
    public List<W4> GetId()
    {
        return (from p in context.w4
                select new W4 { Applicant_ID = p.Applicant_ID }).ToList();

    }
}
我对编程还很陌生,所以非常感谢您的帮助

 public class ApplicationController : Controller
{
    // GET: Application
    public ActionResult Index()
    {

         string template = @"c:\users\carisch\documents\visual studio 2013\Projects\Idea\Idea\fw4.pdf";
        string newFile = @"c:\users\carisch\documents\visual studio 2013\Projects\Idea\Idea\Newfw4.pdf";

        PdfReader reader = new PdfReader(template);
        PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create));

        AcroFields fields = stamper.AcroFields;

        Query num = new Query();

        var query = num.GetId();


        fields.SetField("f1_15_0_", query.ToString());

        stamper.FormFlattening = false;
        stamper.Close();

        return File(@"c:\users\carisch\documents\visual studio     2013\Projects\Idea\Idea\Newfw4.pdf", "application/pdf");   
    }


}