c# linq sql coalesce conversion
<p>I'm trying to convert an existing sql stored proc to use linq. The stored proc uses coalesce() while building up the 'where' clause. </p>

<p>Below is what I've tried. </p>

<p>Can some give advice / other on the correct way to approach this conversion?</p>

<p>------- sql </p>

<pre><code>    if @a is not null 
        set @WhereClause = @WhereClause + ' and v.a_number = ''' + @a + ''''


    if @b is not null 
        set @WhereClause = @WhereClause + ' and v.b_number = ''' + @b + ''''


    if @aDateMin is not null 
        set @WhereClause = @WhereClause + ' and coalesce(v.a_end_dt, v.a_start_dt, ''1/1/1753'') 
            &gt;= ''' + convert(varchar(10), @aDateMin, 101) + ''''


    if @aDateMax is not null 
        set @WhereClause = @WhereClause + ' and coalesce(v.a_start_dt, v.a_end_dt, ''12/31/9999'') 
            &lt;= ''' + convert(varchar(10), @aDateMax, 101) + ''''

set @Sql =      from Results v
                @WhereClause ;';

--print @Sql
exec sp_executesql @Sql
</code></pre>

<p>-----linq </p>

<pre><code>var aNumber = "";
var bNumber = "";
DateTime? aDateMin = null;
DateTime? aDateMax = null;

var query =     from v in searchResults
                select v;

if(!String.IsNullOrEmpty(aNumber )){
    query = query.Where(v =&gt; v.a_number == aNumber);
}

if(!String.IsNullOrEmpty(bNumber)){
    query = query.Where(v =&gt; v.b_number == bNumber);
}


//  this is where I'm having issue with the conversion.
if(aDateMin.HasValue){

    query = query.Where(v =&gt; 
                        v.a_end_dt.HasValue ? v.a_end_dt &gt;= aDateMin : v.a_start_dt.HasValue ? v.a_start_dt &lt;= aDateMin : "1/1/1753");

}
</code></pre>