在开发Windows Phone 8.1应用程序时,无法在Visual Studio中解析符号DataContext或Table / column和System.Data.Linq?

时间:2016-05-05 17:32:39

标签: c# sql windows-phone-8 windows-phone-8.1

我正在制作一个制作Windows手机应用程序的学校项目。目标是8.1,我跟随一个msdn模板,其目标是8.0连接到手机内部sql db。

我的c#:

using System.ComponentModel;
using System.Data.Linq;
namespace No_More_Ramen.Data
{
    public class RecipeDataContext : DataContext
    {
        public RecipeDataContext(string connection) : base(connection)
        {

        }

        public Table<Recipe> Recipes;

        [Table]
        public class Recipe : INotifyPropertyChanged
        {
            private int _recipeId;
            [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert))]
            public int ToDoItemId
            {
                get { return _recipeId; }
                set
                {
                    if (_recipeId != value)
                    {
                        _recipeId = value;
                        NotifyPropertyChanged("RecipeId");
                    }
                }
            }
        }
    }
}

msdn c#

using System;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace LocalDatabaseSample.Model
{

    public class ToDoDataContext : DataContext
    {
        // Pass the connection string to the base class.
        public ToDoDataContext(string connectionString)
            : base(connectionString)
        { }

        // Specify a table for the to-do items.
        public Table<ToDoItem> Items;

        // Specify a table for the categories.
        public Table<ToDoCategory> Categories;
    }

    [Table]
    public class ToDoItem : INotifyPropertyChanged, INotifyPropertyChanging
    {

        // Define ID: private field, public property, and database column.
        private int _toDoItemId;

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

除了一些名称更改之外,语法基本相同,除了我无法弄清楚为什么Resharper / Compiler在抱怨。我的想法是因为我的目标是8.1而不是8,如果是这样的话,在Visual Studio中有一种方法可以将我的目标设置为8.0吗?

0 个答案:

没有答案