I have created a list object
C#
public IReadOnlyList? employeelist{ get; set; }and I am assigning
C#
public string EmployeeType =>
ContentTypes.GetemployeeType(employeelist?._manager, employeelist?.File.address?? string.Empty);here am getting above error;--in (employeelist?._manager, employeelist?.File.address)
class i am using
C#
public class employee:filedetails
{
public employee(IBrowserFile file)
{
File = file ?? throw new ArgumentNullException(nameof(file));
FileName = Path.GetFileName(File.Name);
}
public IBrowserFile File { get; }
}how i can fix these?

Pasang TamangRank #449 · 5.6K reputationPosted Jan 5, 2023, 3:58 AM EST
Hi,
Yes, if you want to return only single item then you will need to convert list into single object by using FirstOrDefault(). If there is some condition that you need to apply while returning single object then you can do like this FirstOrDefault(x=>x.Id). Here Id is just a representation of a field or property. You can use any property that you want to apply filter condition.
Regards,
Pasang
Pasang TamangRank #449 · 5.6K reputationPosted Jan 5, 2023, 3:45 AM EST
Hi,
Looking into your code, your problem is in employeelist?.File.address. employeelist is IReadOnlyList which will represents read only collections. You should make the list to single object first like by using First or FirstOrdefault().
public string EmployeeType => ContentTypes.GetemployeeType(employeelist?._manager, employeelist.FirstOrDefault()?.File.address?? string.Empty);Reagrds,
Pasang
Sujeet RamanRank #1,329 · 1.3K reputationPosted Jan 5, 2023, 3:52 AM EST
public string EmployeeType =>
ContentTypes.GetemployeeType(employeelist?._manager, employeelist.FirstOrDefault()?.File.address?? string.Empty);
here employeelist?._manager, also make the list to single object first like by using First or FirstOrdefault().?