Beispiel #1
0
        //[Obsolete("experimental")]
        public static TElement FirstOrDefault <TElement>(this IQueryStrategy <TElement> source)
        {
            // will it work for jvm?
            var t = new StackTrace(0, true);
            var s = Stopwatch.StartNew();

            Console.WriteLine();

            // X:\jsc.svn\examples\javascript\linq\test\TestSelectAndSubSelect\TestSelectAndSubSelect\ApplicationWebService.cs
            // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectFirstOrDefault\TestSelectFirstOrDefault\ApplicationWebService.cs
            // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectMember\TestSelectMember\ApplicationWebService.cs



            var value = source.Take(1).AsGenericEnumerable().FirstOrDefault();

            var caller = t.GetFrame(1);

            Console.WriteLine(
                Process.GetCurrentProcess().Id.ToString("x4") + ":"
                + Thread.CurrentThread.ManagedThreadId.ToString("x4")
                + " FirstOrDefault " + new { s.ElapsedMilliseconds, Debugger.IsAttached, caller = caller.ToString() });

            return(value);
        }
        public static TElement FirstOrDefault <TElement>(this IQueryStrategy <TElement> source, IDbConnection cc)
        {
            // X:\jsc.svn\examples\javascript\LINQ\test\auto\TestSelect\TestXMySQL\Program.cs
            // make sure the reader will be closed

            // Additional information: Fatal error encountered during command execution.

            var a = source.Take(1).AsEnumerable(cc).ToArray();

            return(a.FirstOrDefault());
        }
        public static async Task <TElement> FirstOrDefaultAsync <TElement>(this IQueryStrategy <TElement> source, IDbConnection cc)
        {
            var x = await source.Take(1).AsEnumerableAsync(cc);

            return(x.FirstOrDefault());
        }