Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 913241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:31:27+00:00 2026-05-15T17:31:27+00:00

I’m using Linq to create a list of objects. Shown below is the expression

  • 0

I’m using Linq to create a list of objects. Shown below is the expression I am using. The problem I have is that at runtime it isn’t happy with the “RawXMLDocument = XElement.Parse(t.Message)” line. The “RawXMLDocument” property takes an XElement. Is there a way to convert the string version of the XML (held in Message) into an XElement as shown below?

var transactionList = (from t in ctx.Transactions
                   where t.MessageRecievedAt >= Start && t.MessageRecievedAt <= End
                   select new TerminalTransactionMessage
                   {
                       DeviceId = t.DeviceId,
                       RawXMLDocument = XElement.Parse(t.Message),
                       TransactionTime = t.EventTime_Local
                   }).ToList();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:31:27+00:00Added an answer on May 15, 2026 at 5:31 pm

    Is the problem that it’s trying to do it in SQL? If so, you need to just separate out the bits to do in SQL and the bits to do in LINQ to Objects. Try this:

    var query = from t in ctx.Transactions
                where t.MessageRecievedAt >= Start && t.MessageRecievedAt <= End
                select new
                {
                    t.DeviceId,
                    t.Message,
                    TransactionTime = t.EventTime_Local
                };
    var transactionList = query.AsEnumerable() // LINQ to Objects from here
                               .Select(t => new TerminalTransactionMessage 
                                       {
                                          DeviceId = t.DeviceId,
                                          RawXMLDocument = XElement.Parse(t.Message),
                                          TransactionTime = t.TransactionTime
                                       });
                               .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to dynamically create a linq expression at runtime using PredicateBuilder from
I have a list of business objects that I want to display in a
Wondering if it's possible to create a dynamic linq query using linq to objects.
I have this contact list which I'm building using LINQ to SQL. The query
i am using LINQ to entity to return a list of objects var st
Has anybody got an idea of how to create a .Contains(string) function using Linq
I am following Scott Gu's article to create a dynamic LINQ http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx He has
How can I create one query using both ICriteria and Linq? Example: var q
When using DataContext.CreateDatabase() to create a database, I wish to stop Linq To Sql
Using LINQ to Entities, how can I determine if any item from a List

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.