code like this:
TB_User_Info{
[Key]
public int PK_ID,
public string sLoginID,
public string sPsw}
DapperExtensions.DapperExtensions.Get<TB_User_Info>(cnn, new {sLoginID=sloginID, sPsw=spsw });
will throw an exception :specified key not in the dictionary ,
in dapperextension.cs line:278
DynamicParameters parameters = new DynamicParameters();
var keys = classMap.Properties.Where(p => p.KeyType != KeyType.NotAKey);
foreach (var key in keys)
{
object value = id;
if (!isSimpleType)
{
value = paramValues[key.Name];//throw exception here
}
parameters.Add("@" + key.Name, value);
}
the sql code is
string sql = _sqlGenerator.Get(classMap);
[
SELECT TB_User_Info
.PK_ID
, TB_User_Info
.sName
, TB_User_Info
.sLoginID
, TB_User_Info
.sPsw
, TB_User_Info
.sUid
, TB_User_Info
.iSex
, TB_User_Info
.iSta
, TB_User_Info
.dCreateTime
FROM TB_User_Info
WHERE TB_User_Info
.PK_ID
= @PK_ID
]
I think PK_ID=@PK_ID is a bug, it would make the Get method can not support nokey field query, it just a primary key query only method ,
like this:
DapperExtensions.DapperExtensions.Get<TB_User_Info>(cnn, new { PK_ID=1, sLoginID=sloginID, sPsw=spsw });
this code will be okay,but useless
I use mysql db,.net4.0
forgive me for the odd english!