Ich verwende DapperLite , einen Port von Dapper , für den Einsatz in Compact Framework. Ich erhalte eine ArgumentException
, keine weiteren Informationen in der folgenden Methode in der angegebenen Zeile der SqlMapper.cs
Datei.
Wirklich kämpfen mit dem, wonach man als nächstes suchen muss oder was eigentlich kaputt ist.
/// <summary>
/// Populate a references type from an IDataRecord by matching column names to property names.
/// </summary>
private static void PopulateClass(object objectClass, IDataRecord reader)
{
Type theType = objectClass.GetType();
PropertyInfo[] p = theType.GetProperties();
// Only set properties which match column names in the result.
foreach (string columnName in GetColumnNames(reader))
{
string colName = columnName;
object value = reader[colName];
PropertyInfo pi = p.FirstOrDefault(x => x.Name == colName);
if (pi == null || value == DBNull.Value) continue;
Type columnType = value.GetType();
Type actualType = Nullable.GetUnderlyingType(pi.PropertyType) ?? pi.PropertyType;
// Check for a directly assignable type
if (actualType == columnType || actualType == typeof(string) || actualType == typeof(int))
{
// Error generated here
pi.SetValue(objectClass, value, null);
}
else
{
value = actualType.GetMethod("Parse", new[] { typeof(string) }).Invoke(null, new[] { value });
pi.SetValue(objectClass, value, null);
}
}
}
Die Werte an diesem Punkt sind objectClass = Models.Employee
und value=1
. Der colName
, weiter oben in der Methode, ist Id
was ein int
im Employee
Modell ist.
Hinzugefügtes Mitarbeitermodell basierend auf Kommentar:
namespace BioPadPunchClock.Models
{
public class Employee
{
public int Id { get; set; }
public int CDB_Employee_PK { get; set; } //Employee PK in the Central DB. If .null., new emp record on this timeclock needs to be pushed to the CDB.
public string Name { get; set; }
//public string FaceImage { get; set; } //path to Jpeg image 136x90 pixels .\NAND\pictures\ named as <pk>.jpg
public DateTime? BirthDate { get; set; }
public string Status { get; set; } //Full Time – Hourly, Inactive, Terminated, Part Time - Hourly
public DateTime? LastPunch { get; set; }
public string LastPunchDirection { get; set; } //IN or OUT
public string PIN { get; set; } // 4 digit
public int CardNum { get; set; } //HID Card Number
public int CardFacCode { get; set; } //HID Card Facility Code
public string FpTemplate { get; set; } //Fingerprint Template (registered fingerprint)
public DateTime? LastUpdate { get; set; } //When this employee record was last sync’d to the CDB. This value will match exactly in the LDB and CDB after a successful sync.
public int DayTotal { get; set; } // Minutes cumulative for the current day at time of last punch
public int PayPeriodTotal { get; set; } //Minutes cumulative for the current pay period at time of last punch
public string Department { get; set; }
public string SSN { get; set; }
public bool ShouldPromptDept { get; set; } //Prompt employee to choose department each time
}
}
Weitere Erkenntnisse ...
Wenn ich meinen Model.Employee
an diesem Punkt Model.Employee
, sagen alle string
dass Could not evaluate expression
mit einem roten Ausrufezeichen Could not evaluate expression
. Ist das ein Hinweis oder normal?
Weitere Erkenntnisse ...
Nicht sicher, ob das wichtig ist oder nicht, aber wenn ich durch den Code actualType == Int32
und die Werte actualType == Int32
ich, dass der actualType == Int32
und der columnType==Int64
während der value
es bewertet, 1
.
Nicht sicher, dass das einen Unterschied macht, da es ein actualType.Equals(typeof(int))
aber ich actualType.Equals(typeof(int))
, ich würde es erwähnen.
Das haben wir mit der letzten Information auf GitHub herausgefunden.
Da die columnType
ist Int64
für die Id
Spalte, die Änderung der Art der Id
- Spalte in dem Modell Int64
wird dieses Problem beheben.