如何从LinQ2Entity查询返回List

时间:2015-06-11 13:20:16

标签: c# linq

我希望从以下LinQ查询返回一个列表,但我不知道如何。这是查询。该方法的返回类型应该是什么以及如何返回?

 public IQueryable<object> getDNISData(int DNIS)
    {
        using (VPEntities VPCtx = new VPEntities())
        {
            var DD = 
                from nm in VPCtx.NumberMaps
                join g in VPCtx.Greetings on nm.Greeting_ID equals g.Greeting_ID
                join p1 in VPCtx.Prompts on nm.Prompt1_ID equals p1.Prompt_ID
                join p2 in VPCtx.Prompts on nm.Prompt2_ID equals p2.Prompt_ID
                join p3 in VPCtx.Prompts on nm.Prompt3_ID equals p3.Prompt_ID
                join p4 in VPCtx.Prompts on nm.Prompt4_ID equals p4.Prompt_ID
                join p5 in VPCtx.Prompts on nm.Prompt5_ID equals p5.Prompt_ID
                join h1 in VPCtx.HoldMsgs on nm.HoldMsg1_ID equals h1.HoldMsg_ID
                join h2 in VPCtx.HoldMsgs on nm.HoldMsg2_ID equals h2.HoldMsg_ID
                join hm in VPCtx.HoldMusics on nm.HoldMusic_ID equals hm.HoldMusic_ID
                join d in VPCtx.Disclaimers on nm.Disclaimer_ID equals d.Disclaimer_ID
                where nm.DNIS == DNIS && nm.Enabled 
                select new {numberID = nm.Number_ID, portfolioID = nm.Portfolio_ID, propertyID = nm.Property_ID, adsource = nm.AdSource_ID
                                    planTypeID = nm.PlanType_ID, greetingFile = g.GreetingFile,  
                                    PromptFile1 = p1.PromptFile,  Accepts1 = p1.Accepts, PromptAction_ID1 = p1.PromptAction_ID,  
                                    PromptFile2 = p2.PromptFile,  Accepts2 = p2.Accepts, PromptAction_ID2 = p2.PromptAction_ID, 
                                    PromptFile3 = p3.PromptFile, Accepts3 = p3.Accepts, PromptAction_ID3 = p3.PromptAction_ID,
                                    PromptFile4 = p4.PromptFile, Accepts4 = p4.Accepts, PromptAction_ID4 = p4.PromptAction_ID, 
                                    PromptFile5 = p5.PromptFile, Accepts5 = p5.Accepts, PromptAction_ID5 = p5.PromptAction_ID,
                                    HoldMsgFile1 = h1.HoldMsgFile, HoldMsgFile2 = h2.HoldMsgFile,
                                    Destination1 = nm.Destination1, Destination2 = nm.Destination2, Destination3 = nm.Destination3,
                                    UIType_ID = nm.UIType_ID,
                                    RingCount = nm.RingCount,
                                    Enabled = nm.Enabled,
                                    Spanish = nm.Spanish,
                                    HoldMusicFile = hm.HoldMusicFile,
                                    Template_ID = nm.Template_ID,
                                    FrontLineForward = nm.FrontLineForward,
                                    DisclaimerFIle = d.DisclaimerFile};
            foreach (var item in DD){
                  IQueryable<object>dd = new List<object>(DD);
            }

0 个答案:

没有答案