varr=awaitconnection.QueryAsync($"SELECT FIRST 1 {keyName} ID FROM {tableName} ORDER BY {keyName} DESC",transaction:transaction,commandTimeout:commandTimeout);
elsethrownewInvalidOperationException("No parsable object was sent in - could not divine any name/value pairs");
else
{
thrownewInvalidOperationException("No parsable object was sent in - could not divine any name/value pairs");
}
returnresult;
}
/// <summary>
...
...
@@ -420,7 +430,7 @@ public virtual dynamic Paged(string where = "", string orderBy = "", string colu
}
varsql=string.Format("SELECT {0} FROM (SELECT ROW_NUMBER() OVER (ORDER BY {2}) AS Row, {0} FROM {3} {4}) AS Paged ",columns,pageSize,orderBy,TableName,where);
varpageStart=(currentPage-1)*pageSize;
sql+=string.Format(" WHERE Row >={0} AND Row <={1}",pageStart,(pageStart+pageSize));
sql+=string.Format(" WHERE Row >={0} AND Row <={1}",pageStart,pageStart+pageSize);
thrownewArgumentOutOfRangeException(string.Format("Parameter '@{0}' specified but only {1} parameters supplied (in `{2}`)",paramIndex,args_src.Length,_sql));
args_dest.Add(args_src[paramIndex]);
}
else
{
// Look for a property on one of the arguments with this name
boolfound=false;
foreach(varoinargs_src)
{
varpi=o.GetType().GetProperty(param);
if(pi!=null)
{
args_dest.Add(pi.GetValue(o,null));
found=true;
break;
}
}
if(!found)
thrownewArgumentException(string.Format("Parameter '@{0}' specified but none of the passed arguments have a property with this name (in '{1}')",param,_sql));
}
return"@"+(args_dest.Count-1).ToString();
if(int.TryParse(param,outintparamIndex))
{
// Numbered parameter
if(paramIndex<0||paramIndex>=args_src.Length)
thrownewArgumentOutOfRangeException(string.Format("Parameter '@{0}' specified but only {1} parameters supplied (in `{2}`)",paramIndex,args_src.Length,_sql));
args_dest.Add(args_src[paramIndex]);
}
else
{
// Look for a property on one of the arguments with this name
boolfound=false;
foreach(varoinargs_src)
{
varpi=o.GetType().GetProperty(param);
if(pi!=null)
{
args_dest.Add(pi.GetValue(o,null));
found=true;
break;
}
}
if(!found)
thrownewArgumentException(string.Format("Parameter '@{0}' specified but none of the passed arguments have a property with this name (in '{1}')",param,_sql));
@@ -15,8 +15,7 @@ public void ParentChildIdentityAssociations()
varparents=connection.Query<Parent,Child,Parent>(@"select 1 as [Id], 1 as [Id] union all select 1,2 union all select 2,3 union all select 1,4 union all select 3,5",
vardata=cnn.Query<PostCE,AuthorCE,PostCE>(@"select * from Posts p left join Authors a on a.ID = p.AuthorID",(post,author)=>{post.Author=author;returnpost;}).ToList();