tags:

views:

71

answers:

2

I am a beginner in LINQ.

I am using .NET 3.5. and VS 2008.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.Linq.Mapping;
using System.Data.Linq.Provider;

namespace LINQ_to_SQL_Test
{
    [Table(Name="Person")]
    public class Person
    {
        [Column(Name="ID", Storage="_ID", DbType="IS NOT NULL IDENTITY", Id=true, AutoGen=true)]
        public int ID { get; set; }
        public int IDRole { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
    }
}

The program was unable to find the definitions for Id and AutoGen in Column attribute.

What can I do?

A: 

There are no such properties in ColumnAttribute. For Id, what you're looking for is probably IsPrimaryKey. Regarding AutoGen, I have no idea what it's supposed to mean in that context...

EDIT: OK, I see what you mean by AutoGen... I think the correct property is IsDbGenerated

Thomas Levesque
+1  A: 

By "[t]he program" I am assuming that you are referring to a C# compiler, and probably csc installed with Visual Studio 2008.

The syntax that you are using to set the properties of the ColumnAttribute is outdated; I believe that syntax was correct when LINQ was released as a CTP. The correct syntax now is:

[Column
    (
    Name="ID",
    Storage="_ID",
    DbType="Int NOT NULL IDENTITY",
    IsPrimaryKey=true,
    IsDbGenerated=true
    )
]

That is, Id has been replaced by IsPrimaryKey and AutoGen has been replaced by IsDbGenerated.

Jason