Example #1
0
 /// <inheritdoc />
 public Task <IEnumerable <T> > FetchAsync <T>(Cql cql)
 {
     //Use ExecuteAsyncAndAdapt with a delegate to handle the adaptation from RowSet to IEnumerable<T>
     _cqlGenerator.AddSelect <T>(cql);
     return(ExecuteAsyncAndAdapt(cql, (s, rs) =>
     {
         var mapper = _mapperFactory.GetMapper <T>(cql.Statement, rs);
         return rs.Select(mapper);
     }));
 }
Example #2
0
        /// <summary>
        /// Adapts a LWT RowSet and returns a new AppliedInfo
        /// </summary>
        internal static AppliedInfo <T> FromRowSet(MapperFactory mapperFactory, string cql, RowSet rs)
        {
            var          row           = rs.FirstOrDefault();
            const string appliedColumn = "[applied]";

            if (row == null || row.GetColumn(appliedColumn) == null || row.GetValue <bool>(appliedColumn))
            {
                //The change was applied correctly
                return(new AppliedInfo <T>(true));
            }
            if (rs.Columns.Length == 1)
            {
                //There isn't more information on why it was not applied
                return(new AppliedInfo <T>(false));
            }
            //It was not applied, map the information returned
            var mapper = mapperFactory.GetMapper <T>(cql, rs);

            return(new AppliedInfo <T>(mapper(row)));
        }