I'm having two tables T1
and T2
.
T1
---------
(Name,Value)
T2
---------
(Name,Value)
I'm trying to make a select on T1
based on Name
and if it doesn't exist then select the row from T2
var T1Row = db.T1.AsNoTracking().Where(s => s.Name == "text1").FirstOrDefault();
if (T1Row == null)
T1Row = db.T2.AsNoTracking().Where(s => s.Name == "text2").FirstOrDefault();
But I'm getting Cannot implicitly convert type T2 to T1
. I'm trying to make this two queries as a single one but I don't know how.
I'm new to C# programming, so please be gentle