I'm trying to create the following query in C# with EntityFrameWork:
SELECT * FROM Companies WHERE Name LIKE '%(searchValue)%';
Company class:
public class Company {
[Key]
public int ID { get; set; }
public string? Name { get; set; }
public int IndustrySegment { get; set; }
public string? Departments { get; set; }
public int MWCustomer { get; set; }
public int ActiveLicense { get; set; }
public string? Employees { get; set; }
public string? Selections { get; set; }
}
This is how C# code is set:
var context = new FILTER_SYSTEM_CONTEXT();
var connectionCompanies = new DAL_SYSTEM<Company>(context);
var searchByName = connectionCompanies
.Where(a => (a.Name ?? "").Contains(searchValue))
.ToList();`
The idea is to search for all companies, returning a List, in this table that may contain the 'searchValue', typed by the user.
But this code keeps returning the following error:
`Data is Null. This method or property cannot be called on Null values.
Value cannot be null. (Parameter 'source')`
Expected: Not facing any "NULL" returns anymore.
What did I try: The fixing I found so far, was to completly fill all those "NULL" values in Companies DB Table. But all that values are suppoed to be optional, so they may be NULL some day.

Companyclass defined in c# (are they nullable)?public class Company { [Key] public int ID { get; set; } public string? Name { get; set; } public int IndustrySegment { get; set; } public string? Departments { get; set; } public int MWCustomer { get; set; } public int ActiveLicense { get; set; } public string? Employees { get; set; } public string? Selections { get; set; }int?-- at least, according to the data sample in your pic, they are null. Also,string?is redundant because string is nullable by default.MWCustomerandActiveLicensesetint?. Thank you!!