Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas 66 posts 88 karma points
    Dec 15, 2011 @ 11:02
    Thomas
    0

    get first node with specific property value

    How do I get the first node with a specific value from a list with Razor?

    I've been trying with something like this;

    @Model.Comments.First().Where("memberID",@member.Id).Where("Visible").Name;
  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Dec 15, 2011 @ 12:18
    Sebastiaan Janssen
    0

    Almost, let's move things around a little:

    @Model.Comments.Where("Visible").Where("memberID = \"" + member.Id + "\"").First().Name;
  • Thomas 66 posts 88 karma points
    Dec 15, 2011 @ 14:51
    Thomas
    0

    That makes sense - it does however not work completely. 

    This works

    Where("memberID = 1200")

    This doesn't

    Where("memberID = \"" + member.Id + "\"")

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Dec 15, 2011 @ 15:13
    Sebastiaan Janssen
    0

    Ah yes sorry, I'm thinking in strings too much! ;)

    So make it: Where("memberId == " + member.Id)

    Oh hang on, just noticed that I did 1 equals signs, instead of 2, so my solution might still work if you put == in there instead of =.

  • Thomas 66 posts 88 karma points
    Dec 15, 2011 @ 16:22
    Thomas
    0

    Yes, I tried that, but it didn't work. 

    Where("memberID == " + member.Id)

    Works perfectly well - Thanks :o)

     

Please Sign in or register to post replies

Write your reply to:

Draft