locked
Please converty SQL Query to LINQ RRS feed

  • Question

  • User559635304 posted

    select * from CTDFields where CategoryTypeDetailId

    in (select CategoryTypeDetailID from CategoryTypeDetail

    where DetailID=4)

    Friday, May 25, 2012 4:26 AM

Answers

  • User3866881 posted

    Hello kishorejetty:)

    in C#,when we want to compare things with each other,we should use "==" instead of "=",So plz have a try like this:

    var dids = CategoryTypeDetail.Where(ctd => ctd.DetailID==4).Select(ctd=>ctd.CategoryTypeDetailID)

    CTDFields.Where(ctd=> dids.Contains(ctd.CategoryTypeDetailId))

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 26, 2012 8:12 PM

All replies

  • User-661350001 posted

    var dids = CategoryTypeDetail.Where(ctd => ctd.DetailID=4).Select(ctd=>ctd.CategoryTypeDetailID)

    CTDFields.Where(ctd=> dids.Contains(ctd.CategoryTypeDetailId))


    Friday, May 25, 2012 4:34 AM
  • User559635304 posted

    Hi,

    Thanks for your response.

    But this code is getting error at where condition of first line and CTDFields at second line.

    Can you please fix this.

    Regards,

    Kishore.Jetty

    Friday, May 25, 2012 4:48 AM
  • User3866881 posted

    Hello kishorejetty:)

    in C#,when we want to compare things with each other,we should use "==" instead of "=",So plz have a try like this:

    var dids = CategoryTypeDetail.Where(ctd => ctd.DetailID==4).Select(ctd=>ctd.CategoryTypeDetailID)

    CTDFields.Where(ctd=> dids.Contains(ctd.CategoryTypeDetailId))

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 26, 2012 8:12 PM