brucezhang80 / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Multi-mapper fails on SqlCE #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
using code very similar to what you posted here: http://snipt.org/xgnph I am 
getting the attached exception.

Here are the POCOs:

    public class Post
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public string Body { get; set; }

        public Author Author { get; set; }
    }

    public class Author
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

and here is the execution code:

            using (var cnn = new SqlCeConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyLittleBlog"].ConnectionString))
            {
                cnn.Open();
                var data = cnn.Query<Post, Author>(@"select * from Posts p left join Authors a on a.ID = p.AuthorID order by p.ID", (post, author) => { post.Author = author; });
                var firstPost = data.First();
                var title = firstPost.Title;
                cnn.Close();
            }

running the query against the db returns results just fine:
ID      Title           AuthorID    Body                Expr1   Name
1   Post number one 1       stuff in the body.  1   Sam Moore
2   post another    1       more body stuff.    1   Sam Moore

Lemme know if you want me to zip this up or git it so you can test if yourself.

When I tried to check the reader in the GetClassDeserializer Method the HasRows 
property was returning an exception("SQL Server Compact does not support calls 
to HasRows property if the underlying cursor is not scrollable.").

Original issue reported on code.google.com by samandmo...@gmail.com on 27 Apr 2011 at 12:37

Attachments:

GoogleCodeExporter commented 9 years ago
I just changed it so we do the split on a case insensitive field named "id" ... 
note it is configurable you can split on any field your pk is. 

also added a test to the source and confirmed sql ce is working

Original comment by sam.saff...@gmail.com on 28 Apr 2011 at 12:17

GoogleCodeExporter commented 9 years ago
awesome job, Sam!

Original comment by samandmo...@gmail.com on 28 Apr 2011 at 12:26