none
the stated type "nvchar" is no valid Type ? NotSupportedException was unhandled? RRS feed

  • Question


  • Hello,

    what is wrong with my code ? See error image at bottom of thread!

    DataContext dataContext = new DataContext(connString);
                Table<Klasse> classMember = dataContext.GetTable<Klasse>();

                var query = from klasse in classMember
                            select new
                                       {
                                           ID = klasse.Klasse_id,
                                           Name = klasse.Name
                            };

                foreach(var row in query)
                {
                    Console.WriteLine("ID: {0} Name: {1}",row.ID,row.Name);
                }

    Klasse.cs

    [Table]
        public class Klasse
        {
            [Column(Name = "klasse_id", DbType = "int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
            public int Klasse_id { get; set; }

            [Column(Name = "name", DbType = "nvchar NOT NULL")]
            public String Name { get; set; }
        }

    error message:



    Tuesday, September 23, 2008 1:45 PM

Answers

  •  natalie74 wrote:
    yeah it seems c# has problems with nva... thx though

     

    Sorry, my first sentence was just a joke.

     

    "nvchar" should probably be "nvarchar" or "nchar". (unless you have a user defined type "nvchar" on the db side)

    Wednesday, September 24, 2008 12:56 AM
    Answerer

All replies

  •  natalie74 wrote:

    [Table]
        public class Klasse
        {
            [Column(Name = "klasse_id", DbType = "int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
            public int Klasse_id { get; set; }

            [Column(Name = "name", DbType = "nvchar NOT NULL")]
            public String Name { get; set; }
        }

     

    Class and property names in German are not allowed as of C# 3.0.

     

     

    Just kidding.... Smile    But nvchar is not a valid type (unless you have declared it as a user defined type in the db) - nvarchar is, and nchar is.

    Tuesday, September 23, 2008 2:59 PM
    Answerer
  • yeah it seems c# has problems with nva... thx though
    Tuesday, September 23, 2008 8:00 PM
  •  natalie74 wrote:
    yeah it seems c# has problems with nva... thx though

     

    Sorry, my first sentence was just a joke.

     

    "nvchar" should probably be "nvarchar" or "nchar". (unless you have a user defined type "nvchar" on the db side)

    Wednesday, September 24, 2008 12:56 AM
    Answerer
  • i know that it was a joke, seems u stepped into my trap Stick out tongue
    Wednesday, September 24, 2008 9:26 AM