RadEntityFrameworkDataSource returns no rows

4 posts, 0 answers
  1. Winfried
    Winfried avatar
    4 posts
    Member since:
    Sep 2008

    Posted 25 May 2015 Link to this post

    Hello,

     i got an application where the RadEntityFrameworkDataSource returns no rows.

    I have written an Test application, which just handles the issue: the problem remains.

    You can download the application at http://w2ww.de/downloads/RadEntityFrameworkDataSource_Test1.zip

    You must edit the connection string in the app.config.

    I used the .Net Framework in the version 4.5 and Telerik Devcraft for WPF in the version 2015.1.0401.45.

     The source:

    namespace RadEntityFrameworkDataSource_Test1 {
        class Program {
            [STAThread]
            static void Main(string[] args) {
                REFDS_T1Context cntxt = new REFDS_T1Context();
                cntxt.Database.CreateIfNotExists();
                if (cntxt.Libraries.FirstOrDefault<Library>() == null) {
                    Library l = new Library("Lib1");
                    cntxt.Libraries.Add(l);
                    l = new Library("Lib2");
                    cntxt.Libraries.Add(l);
                    cntxt.SaveChanges();
                }
                var q = (from m in cntxt.Libraries select m).ToList();
                Console.WriteLine("---- Output from Linq Queryable");
                foreach (Library m in q) {
                    Console.WriteLine(m.Name);
                }
                RadEntityFrameworkDataSource refds = new RadEntityFrameworkDataSource();
                refds.DbContext = cntxt;
                refds.QueryName = "Libraries";
                var l2 = refds.DataView;
                Console.WriteLine("Output from RadEntityFrameworkDataSource");
                var v = l2.TotalItemCount;
                Console.WriteLine("TotalItemCount: " + v);
                foreach (Library m in l2) { //.ToEnumerable<MediaItem>()
                    Console.WriteLine(m.Name);
                }
                Console.WriteLine("---- Ende for Output of: RadEntityFrameworkDataSource");
                Console.ReadLine();
            }
        }
    }

    ----------- The output:

    ---- Output from Linq Queryable
    Lib2
    Lib1
    Output from RadEntityFrameworkDataSource
    TotalItemCount: 0
    ---- Ende for Output of: RadEntityFrameworkDataSource

    ---

    Best Regards

        Winfried Wille

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 May 2015 Link to this post

    Hi Winfred,

    I modified the connection string as suggested and as it turned out, I was not able to load any data as there is not a table Libraries in my database. 
    Would you please try invoking: 
    refds.Load();

    Does this load the results?

    Regards,
    Dimitrina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Winfried
    Winfried avatar
    4 posts
    Member since:
    Sep 2008

    Posted 27 May 2015 in reply to Dimitrina Link to this post

    Hello,

     Load does not fix the problem. There are still no records returned.

    That the database is empty is ok. The program inserts at the begin two rows.

    Code is below.

     

    Regards

    Winfried Wille

     

     class Program {
            [STAThread]
            static void Main(string[] args) {
                REFDS_T1Context cntxt = new REFDS_T1Context();
                cntxt.Database.CreateIfNotExists();
                if (cntxt.Libraries.FirstOrDefault<Library>() == null) {
                    Library l = new Library("Lib1");
                    cntxt.Libraries.Add(l);
                    l = new Library("Lib2");
                    cntxt.Libraries.Add(l);
                    cntxt.SaveChanges();
                }
                var q = (from m in cntxt.Libraries select m).ToList();
                Console.WriteLine("---- Output from Linq Queryable");
                foreach (Library m in q) {
                    Console.WriteLine(m.Name);
                }
                RadEntityFrameworkDataSource refds = new RadEntityFrameworkDataSource();
                refds.Load();
                refds.DbContext = cntxt;
                refds.QueryName = "Libraries";
                var l2 = refds.DataView;
                Console.WriteLine("Output from RadEntityFrameworkDataSource");
                var v = l2.TotalItemCount;
                Console.WriteLine("TotalItemCount: " + v);
                foreach (Library m in l2) { //.ToEnumerable<MediaItem>()
                    Console.WriteLine(m.Name);
                }
                Console.WriteLine("---- Ende for Output of: RadEntityFrameworkDataSource");
                Console.ReadLine();
            }
        }

  5. Winfried
    Winfried avatar
    4 posts
    Member since:
    Sep 2008

    Posted 27 May 2015 Link to this post

    Hello,

     

    in the previous sample, i called load to early. I fixed this, but still no rows are returned.

    Regards

        Winfried Wille

    refds.DbContext = cntxt;
                refds.QueryName = "Libraries";
                refds.Load();

Back to Top