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 3614116
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:12:30+00:00 2026-05-18T22:12:30+00:00

I am developing window phone 7 application in silverlight. I am new to the

  • 0

I am developing window phone 7 application in silverlight. I am new to the silverlight. I am also new to LINQ to XML. In my application the user select the date & submit some transaction details into the application. The details gets stored in XML File. I am using the custom date control in my application for the date selection as follows

 private void DatePicker_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            AppObj = Application.Current as App;
            AppObj.date = (DateTime)EntryDate.Value;         

        }

Then the value of AppObj.date gets stored in the XML file. Sometimes I use the DateTime.Now to store the date in the XML File. Now I want to generate the report of submitted transaction details by querying through LINQ to XML. I want to generate the report for today’s date, current week & current month. For today’s date report I am using the following code

public void GetTransactionObjects(String strXMLFile, DateTime VDateTime)
        {            
            XDocument doc = null;
            XMLFileManager XMLDocObj = new XMLFileManager();
            doc = XMLDocObj.LoadXMLFile(strXMLFile);
            var vTransaction = from s in doc.Descendants("Transaction")
                               .Where(x => x.Element("Current_Date").Value == VDateTime.ToShortDateString())
                               select new Transaction(s);
            this.Clear();
            AddRange(vTransaction);           

        }

The Transaction class contains the following constructor.

public Transaction(XElement xElement)
        {
            Transaction_ID = Convert.ToInt32(xElement.Element("Transaction_ID").Value.ToString());
            TransactionType_ID = Convert.ToInt32(xElement.Element("TransactionType_ID").Value.ToString());
            Alphabet_ID = Convert.ToInt32(xElement.Element("Alphabet_ID").Value.ToString());
            ID = Convert.ToInt32(xElement.Element("ID").Value.ToString());
            SubCategory_ID = Convert.ToInt32(xElement.Element("SubCategory_ID").Value.ToString());
            Item_ID = Convert.ToInt32(xElement.Element("Item_ID").Value.ToString());
            Currency_ID = Convert.ToInt32(xElement.Element("Currency_ID").Value.ToString());
            InputTypeMethod_ID = Convert.ToInt32(xElement.Element("InputTypeMethod_ID").Value.ToString());          
            Principle = Convert.ToInt32(xElement.Element("InputTypeMethod_ID").Value.ToString());
            Interest = Convert.ToInt32(xElement.Element("Interest").Value.ToString());
            ROI = Convert.ToInt32(xElement.Element("InputTypeMethod_ID").Value.ToString());
            Amount = Convert.ToInt32(xElement.Element("InputTypeMethod_ID").Value.ToString());
            Current_Date = Convert.ToDateTime(xElement.Element("Current_Date").Value.ToString());
        }

In the XML File the value gets stored for date & time. The value gets stored as follows

<Transactions>
  <Transaction>
    <Transaction_ID>0</Transaction_ID>
    <TransactionType_ID>0</TransactionType_ID>
    <Alphabet_ID>3</Alphabet_ID>
    <ID>0</ID>
    <SubCategory_ID>0</SubCategory_ID>
    <Item_ID>0</Item_ID>
    <Currency_ID>3</Currency_ID>
    <InputTypeMethod_ID>0</InputTypeMethod_ID>
    <Principle>0</Principle>
    <Interest>0</Interest>
    <ROI>0</ROI>
    <Amount>5000</Amount>
    <Current_Date>2010-12-31T18:08:23.433+05:30</Current_Date>
  </Transaction>
</Transactions>

Look at the node

<Current_Date>2010-12-31T18:08:23.433+05:30</Current_Date>

The date format is yyyy-mm-dd.

Now how should I write the following query to get all the submitted transaction details for today’s date ?

var vTransaction = from s in doc.Descendants("Transaction")
                                   .Where(x => x.Element("Current_Date").Value == VDateTime.ToShortDateString())
                                   select new Transaction(s); 

Similarly how should I write the query to get all the transaction details for the current week & current month? Can you please provide me any code or link through which I can resolve the above issue ? If I am doing anything wrong then please guide me.

  • 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-18T22:12:30+00:00Added an answer on May 18, 2026 at 10:12 pm

    Don’t use Convert.ToDateTime or ToShortDateString etc with LINQ to XML. Use the conversions which already exist in XAttribute and XElement. For example:

    DateTime today = DateTime.Today;
    var query = doc.Descendants("Transaction")
                   .Where(x => ((DateTime) x.Element("Current_Date")).Date == today)
                   .Select(x => new Transaction(s));
    

    (You should use the conversion operator in your Transaction constructor too.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing window phone 7 application. I am new to the silverlight. In
I am developing window phone 7 application. I am new to the silverlight. I
I am developing window phone 7 application. I am new to the silverlight. I
I am developing window phone 7 application in C# & silverlight 4. I am
I am developing window phone 7 application in C#. I am new to the
I am developing window phone 7 application in C#. I am new to the
I am developing window phone 7 application. I am new to the window phone
I am fairly new to silverlight. I am developing on the windows phone platform.
I am developing a Windows Phone 7 Silverlight application that currently displays a map
I'm developing a twitter application for Windows Phone 7 and have been doing some

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.