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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:59:35+00:00 2026-05-31T15:59:35+00:00

I am playing with Linq-To-Sql for the first time on the phone. I have

  • 0

I am playing with Linq-To-Sql for the first time on the phone. I have created a simple class, but anything other than a basic select query, i.e. ‘from p in db.Icons select p’ throws an exception.

        var q = from p in db.Icons
                where p.Name == "testa"
                select p;
        // ^ Throws 'The member Icon.Name has no supported translation to SQL'

I also have 2 more questions in addition to the cause of the exception that are inside the source code I pasted below:

[Column]
private bool _isFavourite = false; // Does this actually set a default value?
                                   // Should I use Nullable<T> for value types?
                                   // i.e. should this be 'bool?' instead.

–

public Table<Icon> Icons
{
    get // Is this getter necessary? Wouldn't 'Table<Icon> Icons' suffice?
    {
        return this.GetTable<Icon>();
    }
}

source:

    //Icon.cs
    [Table]
    public class Icon : INotifyPropertyChanged, INotifyPropertyChanging
    {
        private const string IdPropertyName = "Id";
        private const string NamePropertyName = "Name";
        private const string IsFavouritePropertyName = "IsFavourite";
        private const string IconUrlPropertyName = "IconUrl";

        [Column(IsPrimaryKey=true, IsDbGenerated=true)]
        private int _id;
        [Column]
        private string _name;
        [Column]
        private bool _isFavourite = false; // Does this actually set a default value?
                                           // Should I use Nullable<T> for value types?
                                           // i.e. should this be 'bool?' instead.
        [Column]
        private string _iconUrl; 


        public int Id
        {
            get
            {
                return _id;
            }

            set
            {
                RaisePropertyChanging(IdPropertyName);
                _id = value;
                RaisePropertyChanged(IdPropertyName);
            }
        }

        public string Name
        {
            get
            {
                return _name;
            }

            set
            {
                RaisePropertyChanging(NamePropertyName);
                _name = value;
                RaisePropertyChanged(NamePropertyName);
            }
        }

        public bool IsFavourite
        {
            get
            {
                return _isFavourite;
            }

            set
            {
                RaisePropertyChanging(IsFavouritePropertyName);
                _isFavourite = value;
                RaisePropertyChanged(IsFavouritePropertyName);
            }
        }

        public string IconUrl
        {
            get
            {
                return _iconUrl;
            }

            set
            {
                RaisePropertyChanging(IconUrlPropertyName);
                _iconUrl = value;
                RaisePropertyChanged(IconUrlPropertyName);
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;
        public void RaisePropertyChanging(string propertyName)
        {
            PropertyChangingEventHandler handler = PropertyChanging;
            if (handler != null)
            {
                handler(this, new PropertyChangingEventArgs(propertyName));
            }
        }

    }

–

//IconsManagerContext.cs
public class IconsManagerContext : DataContext
{

    public Table<Icon> Icons
    {
        get // Is this getter necessary? Wouldn't 'Table<Icon> Icons' suffice?
        {
            return this.GetTable<Icon>();
        }
    }

    private const string DbConnectionString = @"DataSource=isostore:/IconsManager.sdf";
    public IconsManagerContext()
        : this(DbConnectionString)
    {

    }

    public IconsManagerContext(string connectionString)
        : base(connectionString)
    {
        if (!DatabaseExists())
        {
            CreateDatabase();
            Icons.InsertAllOnSubmit<Icon>(new List<Icon>()
            { 
             new Icon() { 
                 IconUrl="/Images/testa.jpg",
                 Name="Testa",
                 IsFavourite=true
             },
             new Icon() { 
                 IconUrl="/Images/testb.jpg",
                 Name="Testb",
             }
            this.SubmitChanges();
        }
    }
}

–

//MainPage.xaml
 public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    public MainPage()
    {
        InitializeComponent();
        using (var db = new IconsManagerContext())
        {
            var q = from p in db.Icons
                    where p.Name == "testa"
                    select p;
            // ^ Throws 'The member Icon.Name has no supported translation to SQL'

            IconsListBox.ItemsSource = q;
        }; 
    }
}
  • 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-31T15:59:36+00:00Added an answer on May 31, 2026 at 3:59 pm

    You don’t have a property Named Name and marked as [Column] so you shouldn’t be surprised to get an exception. Mark your properties with [Column] instead of fields and it should work.

    You should read that WP7 SQL CE series: http://windowsphonegeek.com/tips/Windows-Phone-Mango-Local-Database(SQL-CE)-Introduction

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

Sidebar

Related Questions

Playing with jquery for the first time, and I'm trying to get a simple
This is my first time playing around with linq and I can't quite figure
I'm playing with LINQ-To-SQL in .NET 3.5 and have built some classes based on
I've only been playing with linq to sql and lambda expressions for the first
I have been playing about with LINQ-SQL, trying to get re-usable chunks of expressions
I have been playing with some LINQ ORM (LINQ directly to SQL) and I
I have been playing with the Linq to Sql and I was wondering if
I just started playing with Linq to SQL the other day and was curious
Have been playing around with linq but there is one thing I cant seem
I've been playing around with LINQ to SQL and I just have a couple

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.