如何从数据库中检索复选框值。 [英] How to retrieve checkbox values from a database .

查看:94
本文介绍了如何从数据库中检索复选框值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从数据库中检索复选框值。

How to retrieve checkbox values from a database .

推荐答案

复选框值未存储在数据库中。数据库存储例如布尔值或您映射到复选框的内容(如ja表示已选中或nein表示未选中,无差别表示中间状态)。所以,这个问题很难回答,取决于你,我们称之为实施策略(数据库优先,代码优先,模型优先)。但是坚持使用约定并将实体框架用于数据库映射,尤其是当使用代码优先方法时,可能会留下持久性问题,并在那里加载,到框架的魔力(你可以拥有一个很大程度上透明的持久层)。另一种方法是使用注释,流畅的api或其他一些我忘记提及的编程方式,通过手工或实体框架(或任何其他orm / odm框架)将db-module / schema映射到域对象(pocos)。深入研究持久性框架的问题(我使用实体框架来解决)并找出答案。例如,请参阅实体框架代码优先:映射到数据库中的现有表 [ ^ ]

简单来说:将可选对象的布尔属性映射到数据库中的列,让实体框架为您执行绑定,并在代码中以编程方式设置复选框状态。
checkbox values are not stored in a database. the database stores e.g. boolean values or what ever you map to a checkbox (like "ja" for checked or "nein" for unchecked and "indifferent" for intermediate state). so, this question is hard to answer and depending on your, let's call it implementation strategy (database first, code first, model first). however sticking to conventions and using the entity framework for your database mappings, esp. when using the "code first" approach, may leave the persistence concerns, and there for the loading, to the magic of the framework (you can have a largely transparent persistence layer). another approach is mapping your db-module/ schema to your domain objects (pocos) either by hand or entity framework (or any other orm/ odm framework) using either annotations, or a fluent api or some other programming manner I forgot to mention. dive deeper into the matter of persistent frameworks (I sugest using the entity framework) and find out. see for example Entity Framework Code First: Mapping to Existing Table in the Database[^]
in simple words: map a Boolean property of your selectable objects to a column in your database and let the entity framework do the binding for you and set the checkbox state programmatically in your code.


这篇关于如何从数据库中检索复选框值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆