This is a migrated thread and some comments may be shown as answers.

Need small help in LINQ

1 Answer 33 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hari krishna
Top achievements
Rank 1
Hari krishna asked on 26 Jun 2012, 04:31 AM
I'm facing one issue in LINQ


string  filter ="MediCare";  //dynamic(not constant)
var data = GetInsurancePlanList(InsurancefacilityId);

here i'm getting the result

Now i'm trying to filter the result using the string name called filter.

grdInsurancePlans.DataSource = data.Where(p => p.PlanCode.Contains(filter.ToUpper()) || p.PlanType.Tostring().Contains(filter.ToUpper()));

grdInsurancePlans.Rebind();

I able filter the records using "PlanCode" property because "plancode" is a string anyway

My qusetion here is,

I not able filter the records using "PlanType"."PlanType" is an enum.....eventhought i converted to string like above,i couldn't get the results

If i'm worng in doing convertion,can u give a solution?

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 27 Jun 2012, 03:59 PM
This is due to the fact that the database server does not know the string names for the enumeration values, but rather does a '1' or '2' (numeric->string) where you expected the string 'PlanTypeA' or 'PlanTypeB' beeing used.
We do here the translation INT -> VARCHAR on the server, not the Enum->String.

Greetings,
Thomas
the Telerik team
OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
Tags
LINQ (LINQ specific questions)
Asked by
Hari krishna
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or