English 中文(简体)
Does Dapper do an auto-select of columns that match properties?
原标题:
  • 时间:2011-05-16 11:29:03
  •  标签:
  • orm
  • dapper

When using Dapper-dot-net, if your querying to a strongly typed results, and your SQL just has a:

select * 

Will Dapper automappically only do a select on the columns that match the fields in your object? I think PetaPOCO does this but I ran into some problems with dapper that I thought were attributed to this mismatch.

Example,

conn.Query<article>("select * from Article");

Will this work if the Article table contains other columns that are extraneous to the article object?

最佳回答

Yes it does - I tried this over the weekend, even with a query involved two tables joined by a FK constraint. I created two classes that represented only parts of those underlying tables, and those properties present will be filled just fine, anything that s not in the classes will be ignored. Works like a charm!

On the other hand: if you only need a few column - you should really specify those explicitly in your SQL query - as a general best practice! No point in selecting everything, if you need only a handful of columns....

问题回答

暂无回答




相关问题
Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Assistance with CakePHP model relationships

How would I represent the following in a CakePHP model? Product ======= product_id .... Cart ==== cart_id .... Carts_Products ============== cart_id product_id quantity

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How are Models (in MVC) and DAOs supposed to interact?

How are models and DAOs supposed to interact? I m in the process of putting together a simple login module and I m unsure where to put the "business logic." If I put the logic with the data in the ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签