Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Can ibatis.NET return anonymous type
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ron Grabowski  
View profile  
 More options Sep 4 2012, 11:09 am
From: Ron Grabowski <rongrabow...@yahoo.com>
Date: Tue, 4 Sep 2012 08:09:34 -0700 (PDT)
Local: Tues, Sep 4 2012 11:09 am
Subject: Re: Can ibatis.NET return anonymous type

No, anonymous types can't be returned. You can bind an ASP.Net GridView to a Dictionary. Is that not working for you?.

________________________________
 From: Stelio Macumbe <stelio.macu...@gmail.com>
To: mybatisnet-user@googlegroups.com
Sent: Saturday, September 1, 2012 4:25 AM
Subject: Can ibatis.NET return anonymous type

Hi,
I am writing an application which will perform dozens of
reporting queries , since these queries might change frequently I find
it unpractical to create a class for each of them, so I am trying to map
 them to an anonymous class like this:

<select id="FindSalesStatistics" resultClass="System.Object" >
..............
</select>

The
 objects are created but there are no properties in then. I know I could
 use a Dictionary or Hashtable but the problem is that the list will
later be bound to a GridView which does not support dictionaries. 

Is it possible to create the objects with the query columns mapped as properties ?

Thanks for your attention
Stelio


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael McCurrey  
View profile  
 More options Sep 4 2012, 1:50 pm
From: Michael McCurrey <mmccur...@gmail.com>
Date: Tue, 4 Sep 2012 10:50:48 -0700
Local: Tues, Sep 4 2012 1:50 pm
Subject: Re: Can ibatis.NET return anonymous type

I've had this desire as well to return an anonymous type, how many people
would use it?  Would using a dynamic object implemented by interface work?

On Tue, Sep 4, 2012 at 8:09 AM, Ron Grabowski <rongrabow...@yahoo.com>wrote:

--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Tassinari  
View profile  
 More options Sep 4 2012, 2:37 pm
From: Andrea Tassinari <andrea.tassin...@gmail.com>
Date: Tue, 4 Sep 2012 20:37:08 +0200
Local: Tues, Sep 4 2012 2:37 pm
Subject: Re: Can ibatis.NET return anonymous type

On 01/set/2012, at 10:25, Stelio Macumbe <stelio.macu...@gmail.com> wrote:

> Hi,
> I am writing an application which will perform dozens of reporting queries , since these queries might change frequently I find it unpractical to create a class for each of them, so I am trying to map them to an anonymous class like this:

> <select id="FindSalesStatistics" resultClass="System.Object" >
> ..............
> </select>

> The objects are created but there are no properties in then. I know I could use a Dictionary or Hashtable but the problem is that the list will later be bound to a GridView which does not support dictionaries.  

> Is it possible to create the objects with the query columns mapped as properties ?

i have found that the best way is to return a DataTable. ASAP I will post a simple piece of code in order to return a DataTable exploiting all the good stuff of mybatis.

andreat


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael McCurrey  
View profile  
 More options Sep 4 2012, 3:06 pm
From: Michael McCurrey <mmccur...@gmail.com>
Date: Tue, 4 Sep 2012 12:06:53 -0700
Local: Tues, Sep 4 2012 3:06 pm
Subject: Re: Can ibatis.NET return anonymous type

Andrea, if you commit it to the 1.X branch, we can do a patch release.

On Tue, Sep 4, 2012 at 11:37 AM, Andrea Tassinari <

--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Tassinari  
View profile  
 More options Sep 4 2012, 4:01 pm
From: Andrea Tassinari <andrea.tassin...@gmail.com>
Date: Tue, 4 Sep 2012 22:01:22 +0200
Local: Tues, Sep 4 2012 4:01 pm
Subject: Re: Can ibatis.NET return anonymous type

Actually it is a bit quick and dirty and should be refined and provided
with better error handling. This code is implemented in my DAO class
outside myBatis.

I usually map the resultClass as map, but it is not important at this point
(when doing reporting I often use the same select statement used for
mapping class objects.

Heavy reports require specially crafted and optimized sql queries (lots of
join. groupby etc etc) and have them bind to datatable is a must-have in
order to naturally bind to report documents or when lists of objects leads
to performance issues.

In the code the dataTableName parameter could be optional, cannot remember
if I use in client code...

---------------------------------------
public DataTable SelectDataTable(String dataTableName, string
statementName, object parameters)
        {
            DataTable dt = null;
            if (!String.IsNullOrEmpty(dataTableName))
                dt = new DataTable(dataTableName);
            else
                dt = new DataTable();

            IMappedStatement statement =
_mapper.GetMappedStatement(statementName);

            RequestScope scope =
statement.Statement.Sql.GetRequestScope(statement, parameters,
_mapper.OpenConnection());
            statement.PreparedCommand.Create(scope, _mapper.LocalSession,
statement.Statement, parameters);

            using (scope.IDbCommand)
            {
                dt.Load(scope.IDbCommand.ExecuteReader());

            }

            _mapper.CloseConnection();

            return dt;
        }
----------------

this is not my stuff, I found somewhere in the web and just adapted to my
needs.

hope this help

andrea

On Tue, Sep 4, 2012 at 9:06 PM, Michael McCurrey <mmccur...@gmail.com>wrote:

--
--
regards
Andrea Tassinari

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stelio Macumbe  
View profile  
 More options Sep 9 2012, 2:04 am
From: Stelio Macumbe <stelio.macu...@gmail.com>
Date: Sat, 8 Sep 2012 23:04:58 -0700
Local: Sun, Sep 9 2012 2:04 am
Subject: Re: Can ibatis.NET return anonymous type

Hi,

It is actually a winforms application, I tried to bind a dictionary to a
gridview but it doesn't work, after some research I learned it is not
possible

Greetings

On Tue, Sep 4, 2012 at 8:09 AM, Ron Grabowski <rongrabow...@yahoo.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stelio Macumbe  
View profile  
 More options Sep 9 2012, 2:24 am
From: Stelio Macumbe <stelio.macu...@gmail.com>
Date: Sat, 8 Sep 2012 23:24:13 -0700 (PDT)
Local: Sun, Sep 9 2012 2:24 am
Subject: Re: Can ibatis.NET return anonymous type

Hi Andrea,

I will give it a try, I am surprised I haven't considered using data tables
, probably because I am trying to forget the nightmare that was developing
with data sets . Still it would be nice if Ibatis could generate anonymous
objects, it would feel more ibatishy. Do you have any idea if there is some
part I could hack in and accomplish that ? Some extension, plugin , helper
class ,etc ?

Greetings,
Stelio


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stelio Macumbe  
View profile  
 More options Sep 9 2012, 2:35 am
From: Stelio Macumbe <stelio.macu...@gmail.com>
Date: Sat, 8 Sep 2012 23:35:02 -0700 (PDT)
Local: Sun, Sep 9 2012 2:35 am
Subject: Re: Can ibatis.NET return anonymous type

Hi Andreas,
What would cause a list of objects lead to performance issues ? Aren't
POCOs lighter than data tables ?

Thanks for your help
Stelio


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Tassinari  
View profile  
 More options Sep 9 2012, 4:29 am
From: Andrea Tassinari <andrea.tassin...@gmail.com>
Date: Sun, 9 Sep 2012 10:29:46 +0200
Local: Sun, Sep 9 2012 4:29 am
Subject: Re: Can ibatis.NET return anonymous type

On 09/set/2012, at 08:35, Stelio Macumbe <stelio.macu...@gmail.com> wrote:

> Hi Andreas,
> What would cause a list of objects lead to performance issues ? Aren't POCOs lighter than data tables ?

yes poco are lighter in term of memory, but consider doing statistics where you have to load dozens or even hundreds of objects and consider how ibatis maps fields to property. for some reporting porpouses i prefer not to have the goods of object representation in favor if a flat bidimentional data structure (old style). we have built an end user report builder where end user can customize or create his own report  from base reports that have builtin sample data or query.

for some other reports ( invoices, orders etc) we use list of objects.

andrea


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »