sapiens / SqlFu

Fast and versatile .net core data mapper/micro-orm
Other
229 stars 50 forks source link

Propeties with getters should not be included in the query #44

Closed luisvsilva closed 9 years ago

luisvsilva commented 9 years ago

Sometimes you need to extend your object with computed properties, to conform with an interface for instance. This columns with just getters should not be included in queries.

Either that or a ignore attribute to remove that property from all queries

luisvsilva commented 9 years ago

This is an easy fix: Line 72 of SqlFu.Internals.TableInfo:

Columns = t.GetProperties().Where(i=>i.CanWrite).Select(p => p.Name).ToArray();

Let me know if there is interest and I will do a pull request

sapiens commented 9 years ago

The problem is, some people expect mapping to private setters. The best would be to be ignored only if the property has a [Ignore]. Right now, you can specify ignore only as column definition feature used for table generation. I think the behaviour you want should be implemented explicitely with an Ignore attribute. If you go on this route, I'd be interested in a pull request.

luisvsilva commented 9 years ago

Excellent, I will re-use the same [Ignore] now used for the table generation