LINQ to Sharepoint problem with choice fields

I created a list with a choice column called price
Values for example:
5 per user/month
10 per company/month

When I generate the linq to sql entities using spmetal this becomes an enum and it rewrites the values to something like:

Then in a repeater I need to show that data, I need to show the real value.

 protected void WrapsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)

            string price = ((Entities.Wrap)e.Item.DataItem).Price.Value.ToString();
            Literal litprice = (Literal)e.Item.FindControl("WrapPrice");
            litprice.Text = price;


what can I do?
Who is Participating?
mwochnickConnect With a Mentor Commented:
it appears that the default type mapping from spmetal for choice items is an enum this can be configured to be a string - I don't know if that will give the result you desire

here's a example config file - you probably need to do something similar to the Category Column
<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal" xmlns="">
  <ContentType Name="Contact" Class="Contact">
    <Column Name="ContId" Member="ContactId" />
    <Column Name="ContactName" Member="ContactName1" />
    <Column Name="Category" Member="Cat" Type="String"/>
    <ExcludeColumn Name="HomeTelephone" />
  <ExcludeContentType Name="Order"/>
  <List Name="Team Members" Type="TeamMember">
    <ContentType Name="Item" Class="TeamMember" />

Open in new window

here's an article on configuring spmetal
here's an artilcle on configuration Types
here's a link the the choice/mulitchoice item directly

Generate Visual Basic code with custom parameters settings:
SPMetal /web:http://ContosoServer/Marketing /code:MarketingSite.vb /parameters:MarketingSite.xml

Open in new window

I would not recommend using linq to sql to access values in a sharepoint list.  You should use the Sharepoint object model and api.  Microsoft does not guarantee that the database will not change when patching sharepoint, but they make sure the APIs stay the same
Here's a link to the 2007 SDk
and here's a link to the 2010 SDK
here's an artilce about the 2010 SDK
and BTW using the api should return the values in a format you expect
LuisEstebanValenciaAuthor Commented:
I am sorry but that was not my question., I need to know how to return the original value in linq. simple question
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.