c# - Linq to Excel - Object must implement IConvertible error -
the following code showing error
object must implement iconvertible
when adding clause in linq expression compare datetime
field.
i tried use convert.todatetime(c.etc) >= startday
still same error.
var excel = new excelqueryfactory(excelfilename); excel.addmapping<bulkmovementitem>(x => x.etc, "etc"); var newrailtruckmovements = (from c in excel.worksheet<bulkmovementitem>(sheetname) c.etc > new datetime(2015, 7, 1) select c);
definition of bulkmovementitem
:
public class bulkmovementitem { public string schedulename { get; set; } public string dealheadername { get; set; } public string dealdetailname { get; set; } public string etc { get; set; } public string railcarname { get; set; } public string location { get; set; } public string originlocation { get; set; } public string functiontype { get; set; } public string productname { get; set; } public string volume { get; set; } public string supplieruniquenbr { get; set; } // error description public string status { get; set; } public bool haserrors { get; set; } //public list<string> errordetails { get; set; } }
you need change etc
's type in class datatime
. library rest:
public class bulkmovementitem { // fields... public datetime etc { get; set; } // rest of fields... }
and work:
var rows = c in excel.worksheet<bulkmovementitem>(sheetname) c.etc > new datetime(2015, 7, 1) select c;
Comments
Post a Comment