Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

While trying to concatenate a string, I am getting expression tree cannot contain value of ref struct or restricted type error

$
0
0

I have a method that pulls data from DB and then assigns it to a Model for use in other places. I am getting address details from the db in different parameters as shown below. While concatenating the string values, I am getting below error.

Please help me with this.

Expression tree cannot contain value of ref struct or restricted type.

An expression tree may not contain an expanded form of non-array params collection parameter.

The code below

 public async Task<InvoiceLocationDTO> GetLocationDetails(int locId) {     try     {         InvoiceLocationDTO? locationDetails = await (             from loc in context.Location.Where(loc => loc.Id == locId)             .Include(x => x.LocationAddress)                          select new InvoiceLocationDTO             {                 ///Getting error in below line                 BillToAddress = string.Format(" {0}, {1}, {2}, {3}, {4}",                                 loc.LocationAddress.Address, loc.LocationAddress.AddressExtraLine, loc.LocationAddress.City, loc.LocationAddress.State.Name, loc.LocationAddress.Zip)                                 .Replace(" ,", string.Empty).TrimEnd(','),             }         ).FirstOrDefaultAsync();         return locationDetails;     }     catch (Exception ex)     {         throw ex;     } }

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>