Beispiel #1
0
        public static ResultDyn ExecProcResultDyn(this ISqlProc proc
                                                  , Action <SqlCommand> setupCmd = null
                                                  , Action <Exception> onError   = null)
        {
            SqlDataReader reader = null;

            return(DbEnumeratorData.GetResultDyn(SqlMultiDyn.LazyReader(proc, (r) => reader = r, setupCmd, onError)));
        }
Beispiel #2
0
        public static ResultDyn ExecNamedResultDyn(this Context db, object named
                                                   , Action <SqlCommand> setupCmd = null
                                                   , Action <Exception> onError   = null)
        {
            var           proc   = SqlProcExt.ProcNamed(named, db);
            SqlDataReader reader = null;

            return(DbEnumeratorData.GetResultDyn(LazyReader(proc, (r) => reader = r, setupCmd, onError)));
        }
Beispiel #3
0
        public static KeyValuePair <ResultDyn, IEnumerable <T> > ResultObj <T>(this Context db, object named
                                                                               , Action <SqlCommand> setupCmd = null
                                                                               , Action <Exception> onError   = null)
        {
            var           proc   = SqlProcExt.ProcNamed(named);
            SqlDataReader reader = null;
            ResultDyn     dyn    = DbEnumeratorData.GetResultDyn(LazyReader(proc, (r) => reader = r, setupCmd, onError));

            return(CastResult <T>(dyn, onError));
        }
Beispiel #4
0
        public static XElement ExecMergeXElem(this Context db, object namedParam
                                              , string[] elemNames
                                              , Action <SqlCommand> setupCmd = null)
        {
            KeyValuePair <SqlDataReader, DbEnumeratorData <ExpandoObject> > firstSet = db.ExecDyn(namedParam, setupCmd);
            var reader    = firstSet.Key;
            var numerator = firstSet.Value;

            Guard.Check(elemNames.Length >= 2);
            var retElement = new XElement(elemNames[0]);
            var rootName   = elemNames[1];

            var depth = reader.Depth;
            int index = 1;

            while (numerator.MoveNext())
            {
                var expando = numerator.Current as ExpandoObject;
                retElement.Add(expando.Convert(rootName));
            }
            numerator.Dispose();

            while (!reader.IsClosed)
            {
                if (!reader.NextResult())
                {
                    break;
                }

                index++;
                rootName = elemNames.Length <= index ? "Node" + index.ToString()
                         : elemNames[index];
                var result2 = DbEnumeratorData.GetResultDyn(() => { return(reader); });

                while (result2.MoveNext())
                {
                    // yield return
                    XElement elem = result2.Current.Convert(rootName);
                    retElement.Add(elem);
                }

                result2.Dispose();
            }

            return(retElement);
        }