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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:46:45+00:00 2026-05-10T19:46:45+00:00

I have a string column in a database table which maps to an Enum

  • 0

I have a string column in a database table which maps to an Enum in code. In my dbml file when I set the ‘Type’ to MyTypes.EnumType I get the following error:

Error 1 DBML1005: Mapping between DbType ‘VarChar(50) NOT NULL’ and Type ‘MyTypes.EnumType’ in Column ‘EnumCol’ of Type ‘Table1’ is not supported.

This question: LINQ to SQL strings to enums indicates that what I am trying to do is possible, but how is it done?

  • 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. 2026-05-10T19:46:45+00:00Added an answer on May 10, 2026 at 7:46 pm

    Curious – it should work IIRC; I’ll see if I can do a quick example – however, you might want to check that you have the fully-qualified enum name (i.e. including the namespace).

    [update] From here it seems that the RTM version shipped with a bug when resolving the enum. One workaround suggested (on that page) was to add the global:: prefix. It works fine for me without this workaround, so maybe it is fixed in 3.5 SP1? It also allegedly works fine in 3.5 if you use the unqualified name if the enum is in the same namespace.

    [example] Yup, worked fine: with Northwind, I defined an enum for the shipping country:

    namespace Foo.Bar {     public enum MyEnum     {         France,         Belgium,         Brazil,         Switzerland     } } 

    I then edited the dbml to have:

    <Column Name='ShipCountry' Type='Foo.Bar.MyEnum' DbType='NVarChar(15)' CanBeNull='true' /> 

    This generated:

    private Foo.Bar.MyEnum _ShipCountry; //... [Column(Storage='_ShipCountry', DbType='NVarChar(15)', CanBeNull=true)] public Foo.Bar.MyEnum ShipCountry { get {...} set {...} } 

    And finally wrote a query:

    using (DataClasses1DataContext ctx = new DataClasses1DataContext()) {     var qry = from order in ctx.Orders               where order.ShipCountry == Foo.Bar.MyEnum.Brazil                 || order.ShipCountry == Foo.Bar.MyEnum.Belgium               select order;     foreach (var order in qry.Take(10))     {         Console.WriteLine('{0}, {1}', order.OrderID, order.ShipCountry);     } } 

    Worked fine; results:

    10250, Brazil 10252, Belgium 10253, Brazil 10256, Brazil 10261, Brazil 10287, Brazil 10290, Brazil 10291, Brazil 10292, Brazil 10299, Brazil 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The simple answer is: stop what you're doing. You don't… May 11, 2026 at 2:08 pm
  • added an answer EDIT: This fails the 'constant space' constraint - it basically… May 11, 2026 at 2:08 pm
  • added an answer It is probably blocking on the call to connect, after… May 11, 2026 at 2:08 pm

Related Questions

If I have a database containing only varchar columns, with strings encoded in Latin-1
I have a column of data that contains a percentage range as a string
I have a label function like : private function formatDate (item:Object, column:DataGridColumn):String { var
I have a column containing the strings 'Operator (1)' and so on until 'Operator
I have a certain POJO which needs to be persisted on a database, current
This is basic stuff, but I'm somewhat unfamiliar with VBA and the Word/Access object
I have a project here that connects to an in-production database and grabs tables
I am trying to work out the best database model for the current setup:

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.