ginni zed

ginni zed

  • NA
  • 1
  • 1.4k

What is wrong in this query

Oct 12 2012 1:45 AM

I have a list AllIDs.
List<IAddress> AllIDs = new List<IAddress>();
I want to to substring operation on a member field AddressId based on a character "_".

I am using below LINQ query but getting compilation error:

AllIDs= AllIDs.Where(s => s.AddressId.Length >= s.AddressId.IndexOf("_")).Select(s => s.AddressId.Substring(s.AddressId.IndexOf("_"))).ToList();


Error:

Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<MyCompany.Common.Users.IAddress>'

I have a list AllIDs.
List<IAddress> AllIDs = new List<IAddress>();
I want to to substring operation on a member field AddressId based on a character "_".

I am using below LINQ query but getting compilation error:

AllIDs= AllIDs.Where(s => s.AddressId.Length >= s.AddressId.IndexOf("_")).Select(s => s.AddressId.Substring(s.AddressId.IndexOf("_"))).ToList();


Error:

Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<MyCompany.Common.Users.IAddress>'

 


Answers (1)