Need small help in LINQ

Thread is closed for posting
2 posts, 0 answers
  1. Hari krishna
    Hari krishna  avatar
    13 posts
    Member since:
    Jul 2012

    Posted 25 Jun 2012 Link to this post

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


    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?
  2. Thomas
    Thomas avatar
    590 posts

    Posted 27 Jun 2012 Link to this post

    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.

    the Telerik team
    OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
Back to Top