如何使用Entity Framework修剪字符串?

时间:2015-09-22 23:06:01

标签: c# entity-framework

如何让Entity Framework在将所有字符串存储到数据库之前自动修剪它们?

1 个答案:

答案 0 :(得分:9)

您可以使用class LineItem { int id Header header static mapping = { table "line_item" columns { header { column name: 'sale_id' column name: 'store_id' } } id composite: ['id', 'header.station.storeId'] // something like this where I have to include store_id along from header table which instead from station table should be included as a part of composite key } } 拦截对数据库的所有调用。然后修剪任何传递的参数。

有关详细信息,请参阅this article,尤其是如何注册拦截器。

IDbCommandInterceptor