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

  • SEARCH
  • Home
  • 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 6566743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:15:08+00:00 2026-05-25T14:15:08+00:00

I’m very new to C#/LINQ/WP7 development and am struggling to format data being returned

  • 0

I’m very new to C#/LINQ/WP7 development and am struggling to format data being returned from my LINQ query.

I have the following LINQ c# structure:

var boughtItemsInDB = from DBControl.MoneySpent bought in BoughtItemDB.BoughtItems
select bought;

BoughtItems = new ObservableCollection<DBControl.MoneySpent>(boughtItemsInDB);

The definition for MoneySpent is below;

    [Table(Name = "MoneySpent")]
    public class MoneySpent : INotifyPropertyChanged, INotifyPropertyChanging
    {
        // Define ID: private field, public property and database column.
        private int _itemId;

        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int ItemId
        {
            get
            {
                return _itemId;
            }
            set
            {
                if (_itemId != value)
                {
                    NotifyPropertyChanging("ItemId");
                    _itemId = value;
                    NotifyPropertyChanged("ItemId");
                }
            }
        }

        // Define item budget: private field, public property and database column.
        private int _itemBudget;

        [Column]
        public int ItemBudget
        {
            get
            {
                return _itemBudget;
            }
            set
            {
                if (_itemBudget != value)
                {
                    NotifyPropertyChanging("ItemBudget");
                    _itemBudget = value;
                    NotifyPropertyChanged("ItemBudget");
                }
            }
        }


        // Define item category: private field, public property and database column.
        private string _itemCategory;

        [Column]
        public string ItemCategory
        {
            get
            {
                return _itemCategory;
            }
            set
            {
                if (_itemCategory != value)
                {
                    NotifyPropertyChanging("ItemCategory");
                    _itemCategory = value;
                    NotifyPropertyChanged("ItemCategory");
                }
            }
        }



        // Define item description: private field, public property and database column.
        private string _itemDescription;

        [Column]
        public string ItemDescription
        {
            get
            {
                return _itemDescription;
            }
            set
            {
                if (_itemDescription != value)
                {
                    NotifyPropertyChanging("ItemDescription");
                    _itemDescription = value;
                    NotifyPropertyChanged("ItemDescription");
                }
            }
        }



        // Define item amount: private field, public property and database column.
        private decimal _itemAmount;

        [Column]
        public decimal ItemAmount
        {
            get
            {
                return _itemAmount;
            }
            set
            {
                if (_itemAmount != value)
                {
                    NotifyPropertyChanging("ItemAmount");
                    _itemAmount = value;
                    NotifyPropertyChanged("ItemAmount");
                }
            }
        }


        // Define item date: private field, public property and database column.
        private DateTime _itemDateTime;

        [Column]
        public DateTime ItemDateTime
        {
            get
            {
                return _itemDateTime;
            }
            set
            {
                if (_itemDateTime != value)
                {
                    NotifyPropertyChanging("ItemDateTime");
                    _itemDateTime = value;
                    NotifyPropertyChanged("ItemDateTime");
                }
            }
        }

I need to format the data returned from the database, the following is stored in my DB:

ItemDateTime – DateTime, ItemDescription – String, ItemAmount – Decimal

I need to be able to to format the Date based on the current locale of the user, and format the decimal to 2 dp.

I am also not sure if I need to use IQueryable when I get the data results .

Any help would be much appreciated.

Thanks,
Mark

  • 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-25T14:15:08+00:00Added an answer on May 25, 2026 at 2:15 pm

    Since you don’t provide enough detail – just a general idea

    var boughtItemsInDB = from bought in BoughtItemDB.BoughtItems
    select new { ItemDateTime = bought.ItemDateTime.ToString(), ItemDescription = bought.ItemDescription, ItemAmount = bought.ItemAmount.ToString("0,0.00") };
    

    BUT formatting is better done in the control you use to display the data, not in the Linq query…

    EDIT – after the addition frm OP:

    From what I see the MoneySpent class is already prepared for “data binding”…

    So formatting should be done in the displaying control… for some information see:

    • What is the WPF XAML Data Binding equivalent of String.Format?
    • http://www.codeproject.com/KB/WPF/binding_in_linq-sql.aspx
    • http://odetocode.com/code/740.aspx
    • http://www.codeguru.com/csharp/.net/wp7/article.php/c18933
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.