What is the similar query to below code in entity framework c#.
SELECT StudentId,Coalesce(s.FName + ' ' + s.MName + ' ' + s.LName,
s.FName + ' ' + s.MName,
s.FName) AS FullName
FROM Student s
WHERE s.StudentId = 'S101';
Thanks in advance.
CsharpProgrammingServer Side Programming. The null coalescing operator is used with the nullable value types and reference types. It is used for converting an operand to the type of another nullable (or not) value type operand, where an implicit conversion is possible.
Coalesce(Expression, Expression, LambdaExpression) Creates a BinaryExpression that represents a coalescing operation, given a conversion function. Coalesce(Expression, Expression) Creates a BinaryExpression that represents a coalescing operation.
Have a look at null-coalescing operator
e.g.
string text1 = null;
string result = text1 == null ? "default" : text1 ;
you can do
string result = text1 ?? "default";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With