Exemplo n.º 1
0
        public static TRow TrySingle <TRow>(this IDbConnection connection, Action <SqlQuery> editQuery)
            where TRow : class, IRow, new()
        {
            var row = new TRow()
            {
                TrackWithChecks = true
            };
            var query = new SqlQuery().From(row);

            editQuery(query);

            if (query.GetSingle(connection))
            {
                return(row);
            }

            return(null);
        }
Exemplo n.º 2
0
        public static TRow TryById <TRow>(this IDbConnection connection, object id, Action <SqlQuery> editQuery)
            where TRow : class, IRow, IIdRow, new()
        {
            var row = new TRow()
            {
                TrackWithChecks = true
            };
            var query = new SqlQuery().From(row)
                        .Where(new Criteria(row.IdField) == new ValueCriteria(id));

            editQuery(query);

            if (query.GetSingle(connection))
            {
                return(row);
            }

            return(null);
        }