locked
How do I call LINQ method in generic handler? RRS feed

  • Question

  • I have a table for project meetings (PRJ_MTGS) and I want to get the value of the meeting agenda field (MTG_AGNDA).

    So in this case, I just need the string value of PRJ_MTG.MTG_AGNDA not the queryable record set.

    I do not know how to call the method to return the value.

    The use case is to create a Outlook object which is working fine. But the email body needs the agenda which is a html string. I pass some data points, like the recipient, when I call the handler, but the html string would be too long for this method.

    myapp.ViewTSA_PRJ_MTG.CreateInvite_execute = function (screen) {
         window.open("../Web/MeetingInvites.ashx?recip=" + recips );
    };

    Consider the LINQ query in my c# class handler (.ashx.cs):

    namespace LightSwitchApplication.Web
    {
        /// <summary>
        /// Summary description for MeetingInvites
        /// </summary>
        public class MeetingInvites : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                string mtgAgnda = //?????
            }
            string mtgContext(ref IQueryable<TSA_PRJ_MTG> entity)
            {
                var qry = (from a in entity
                            where a.PRJ_MTGS_PK == 10
                            select a.MTG_AGENA).FirstOrDefault();
                return qry;
            }
        }
    }
    Thanks!

    Saturday, December 31, 2016 6:41 PM

Answers

  • Hello,

    do you mean this?

        public void ProcessRequest(HttpContext context)
        {
            var recips = Convert.ToString(context.Request.Params("recips"));
            using (ServerApplicationContext Ctx = ServerApplicationContext.CreateContext())
            {
                var erg = (from a in Ctx.DataWorkspace.Data.table where a.PRJ_MTGS_PK == 10).FirstOrDefault;
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(erg.tostring());
    
        }

    Hope this helps.

    Kind Regards

    Thomas

    • Marked as answer by FaithNoMore Tuesday, January 10, 2017 5:24 PM
    Monday, January 9, 2017 4:48 PM

All replies