Compare

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Compare

    Hi,

    In a Linq query I have the following:

    where t.Name == tag

    How can I make this line to have no effect if tag is empty?
    In this moment if tag is empty I don't get any record.

    tag is a string.

    Thank You,
    Miguel
  • Chris Dunaway

    #2
    Re: Compare

    On Sep 29, 12:21 pm, shapper <mdmo...@gmail. comwrote:
    Hi,
    >
    In a Linq query I have the following:
    >
    where t.Name == tag
    >
    How can I make this line to have no effect if tag is empty?
    In this moment if tag is empty I don't get any record.
    >
    tag is a string.
    >
    Thank You,
    Miguel
    What do you mean when you say, "tag is empty"? How is tag defined?
    Is it of type System.Object? or is it a string?

    You could try using something like:

    where t.Name == tag || tag == null //Or whatever is appropriate
    for an "empty" tag.

    Not sure if this is what you need.

    Chris

    Comment

    Working...