This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm getting an exception "Index was outside the bounds of the array" when executing the Linq below. The exception is not thrown if I just set IsForeclosure = true instead of setting it the conditions. From my testing it seems that the problem is in converting ToList and it has something to do with the way the result set is returned. var rslt = (from p in uow.Properties where // Subdivision. p.PropertySubdivision.Contains(subdivision) // Sqft. && p.PropertySqFt >= (sqft - sqftOffset) && p.PropertySqFt <= (sqft + sqftOffset) // Bedrooms. && p.PropertyBedrooms >= minBed && p.PropertyBedrooms <= maxBed // Bathrooms. && p.PropertyFullBaths >= minBath && p.PropertyFullBaths <= maxBath // Garage. && p.PropertyGarageSpaces >= minGarageSpaces && p.PropertyGarageSpaces <= maxGarageSpaces // Year built. && p.PropertyYearBuilt >= (yearBuilt - yearBuiltOffset) && p.PropertyYearBuilt <= (yearBuilt - yearBuiltOffset) // Months closed. && p.MlsDateSold >= (DateTime.UtcNow.AddMonths(monthsClosed * -1)) // Market. && p.MarketId == (int)market // Must be residential. && p.MlsPropertyCategory.Equals(Constants.MlsPropertyCategory_RESIDENTIAL) // Sold. && p.MlsListingStatusType.Equals(Constants.MlsListingStatusType_SOLD) select new SaleCompPropertyDto { IncludedInCalculation = true, MlsNumber = p.MlsNumber, PropertyStreet = p.PropertyStreetNumber + " " + p.PropertyStreetName, PropertySubdivision = p.PropertySubdivision, PropertyBedrooms = p.PropertyBedrooms, PropertyFullBaths = p.PropertyFullBaths, PropertySqFt = p.PropertySqFt, MlsPriceList = p.MlsPriceList, MlsPriceSales = p.MlsPriceSales, PricePerSqFt = (float)((float)p.MlsPriceSales.Value / (float)p.PropertySqFt.Value), IsForeclosure = ( p.MlsIsForeclosure == true || p.MlsDescriptionPrivate.Contains("foreclos") || p.MlsDescriptionPrivate.Contains("bank owned") || p.MlsDescriptionPrivate.Contains("corporate owned") || p.MlsDescriptionPrivate.StartsWith("hud") || p.MlsDisclosures.Contains("forcl") ) }).ToList();
|
|
|
Thanks for reporting this issue. This was a bug with handling logical expressions (&& and || clauses) in a projection. I have committed a candidate fix which will be included in nightly builds dated 16 Feb 2010 and above, available from about 1500 GMT. Caveat: I haven't tested this with an expression quite as complex as yours -- do let us know if you still see problems. |
|