Link to home
Start Free TrialLog in
Avatar of LuisEstebanValencia
LuisEstebanValenciaFlag for Belgium

asked on

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:
_5peruser_month
_10_percompany_month


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)
                return;


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

        }

what can I do?
Avatar of mwochnick
mwochnick
Flag of United States of America image

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 http://msdn.microsoft.com/en-us/library/ms550992%28v=office.12%29.aspx
and here's a link to the 2010 SDK
http://msdn.microsoft.com/en-us/library/ms550992%28v=office.12%29.aspx
here's an artilce about the 2010 SDK
http://blogs.msdn.com/b/randalli/archive/2010/05/24/download-the-sharepoint-2010-sdk-software-development-kit.aspx
and BTW using the api should return the values in a format you expect
Avatar of LuisEstebanValencia

ASKER

I am sorry but that was not my question., I need to know how to return the original value in linq. simple question
ASKER CERTIFIED SOLUTION
Avatar of mwochnick
mwochnick
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial