I have an asp.net app written in VS2012. I was using LinqToExcel without any problems until I moved to VS2015. Here is my code:
var excel = new ExcelQueryFactory(fileName);
var entriesQuery = from entry in excel.Worksheet<VEntry>(0)
where entry.MovieTitle != null
select entry;
var entries = entriesQuery.ToList();
VEntry class
public class VEntry
{
[ExcelColumn("id kolekcji")]
[DefaultValue("")]
public String CollectionId { get; set; }
[ExcelColumn("nazwa kolekcji")]
[DefaultValue("")]
public String CollectionName { get; set; }
[ExcelColumn("Tytuł serialu/serii/filmu")]
[DefaultValue("")]
public String MovieTitle { get; set; }
[ExcelColumn("Tytuł odcinka")]
[DefaultValue("")]
public String EpisodeTitle { get; set; }
[ExcelColumn("Sezon")]
[DefaultValue("")]
public String Season { get; set; }
[ExcelColumn("nr odcinka")]
[DefaultValue("")]
public String EpisodeNumber { get; set; }
[ExcelColumn("Start")]
public DateTime StartDate { get; set; }
[ExcelColumn("Koniec")]
public DateTime EndDate { get; set; }
[ExcelColumn("Kategoria tematyczna")]
[DefaultValue("")]
public String Category { get; set; }
[ExcelColumn("Cena")]
[DefaultValue("")]
public String Price { get; set; }
[ExcelColumn("kategoria wiekowa")]
[DefaultValue("")]
public String AgeCategory { get; set; }
[ExcelColumn("Seria (0/1)")]
[DefaultValue("")]
public bool IsSeries { get; set; }
[ExcelColumn("box set (0/1)")]
[DefaultValue("")]
public bool IsBoxSet { get; set; }
[ExcelColumn("Cały sezon")]
[DefaultValue("")]
public bool IsFullSeason { get; set; }
}
It worked fine on VS2012. When I build it in VS2015 I get exception at line
var entries = entriesQuery.ToList();
:
Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at LinqToExcel.Extensions.CommonExtensions.Cast(Object object, Type castType)
at LinqToExcel.Extensions.CommonExtensions.Cast[T](Object object)
at LinqToExcel.Extensions.CommonExtensions.IsNullValue(Expression exp)
at LinqToExcel.Query.WhereClauseExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression bExp)
at LinqToExcel.Query.SqlGeneratorQueryModelVisitor.VisitWhereClause(WhereClause whereClause, QueryModel queryModel, Int32 index)
at Remotion.Data.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel)
at LinqToExcel.Query.SqlGeneratorQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
at LinqToExcel.Query.ExcelQueryExecutor.GetSqlStatement(QueryModel queryModel)
at LinqToExcel.Query.ExcelQueryExecutor.ExecuteCollection[T](QueryModel queryModel)
at Remotion.Data.Linq.Clauses.StreamedData.StreamedSequenceInfo.ExecuteQueryModel(QueryModel queryModel, IQueryExecutor executor)
at Remotion.Data.Linq.QueryProviderBase.Execute[TResult](Expression expression)
at Remotion.Data.Linq.QueryableBase`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Logic.Importers.VodImporter.VodImporter.Run(String fileName, Boolean publishAfterImport) in C:\ncplus\npl\Logic\Importers\VodImporter\VodImporter.cs:line 103
at Website.sitecore_modules.Shell.Editors.VodImporterEditor.Page_Load(Object sender, EventArgs e)
But when I build it in VS2012 it works again. What may be wrong? I have no idea.
Edit: On VS2013 it works too.