问题标签 [readonly]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - NHibernate- Prevent deletion on a particular entity (i.e. make read-only)
How can I prevent NHibernate from deleting a single entity of a specific class? A programmatic way I am using at the moment entails checking for the entity's unique field "Name".
Here's the scenario: I have a person and a group. The group can have persons and other groups. If the group named "Admins" is attempted to be deleted, it will not, due to transaction-level constraints that I enforce (specifically checking for the group's 'Name' column/field, as this is unique). So that's fine.
But now I'm thinking that if another group is created and the "Admins" becomes a sub-group of that, the check will fail. This will mean the deletion of "Admins". So I'm looking for a better way, other than traversing the parent/child containment tree, e.g. using NHibernate
I can't use a class-wide restriction such as 'class Mutable=false', I mean having a read-only restriction on one or two individual entities of a certain class.
Regards,
_NT
c# - 有没有办法使只读(不仅仅是私有)自动属性?
自动属性让我替换此代码:
使用此代码:
在这里和那里进行了一些更改-但是有没有办法替换此代码:
有类似的东西?
c# - 为什么 resharper 建议只读字段
为什么 ReSharper 在下面的示例中建议“设置”的只读字段?
如果我理解正确,如果仅在构造函数中更改此字段,则应使用readonly
修饰符,但在我的示例中,我也在同一个类的另一个方法中更改它。
我错过了什么?
ruby-on-rails - 在只读文件系统上使用 rails 从 temp 提供文件
我现在将我的应用程序部署到具有只读文件系统的服务器上。我正在使用 gem 制作一个 zip 文件并随机将其放入 /public 某处。现在我只能写入 tmp - 如何从 tmp 文件夹中为用户提供该文件?
c# - 是否可以有只能分配一次的字段?
我需要一个可以从我想要的任何地方分配到的字段,但是应该只能分配一次(因此应该忽略后续分配)。我怎样才能做到这一点?
c# - 在 C# 中,方法可以返回 List 以便客户端只能读取它,但不能写入它吗?
假设我有一个 C# 类:
客户可以这样称呼它:
有没有办法使Add
方法失败,因为只返回只读版本_barList
?
c# - 集合上下文中 ReadOnlyCollection string[] 的区别
在这两种情况下,我都不能使用“Add()”方法来添加新项目。那么几乎两个声明都是一样的?
c# - 以只读方式打开文件
在 C# WinForms 应用程序中,我使用 System.IO.Diagnostics.Process.Start(fileName) 打开文件。文件类型可以是 .doc、.docx、.xls、.xlsx、.csv、.pdf 或 .txt。
有没有办法强制这些文件以只读方式打开?
iphone - Core Data 对只读数据也有用吗?
我正在创建一个 iPhone 应用程序,并且想知道 Core Data 是否比 SQLite 数据库更适合只读数据。感觉 SQLite DB 是更好的选择,对吗?我什至可以预先填充核心数据存储吗?
基本上,我需要 3 个表,每个表都有一堆(最多 3000 个)实体。然后,我想在 TableViews 中列出数据,对其进行搜索或加载其他内容。
在这种情况下,我应该或可以使用 Core Data 吗?
git - 如何使 git 存储库只读?
我有一些通过 SSH 远程访问的 git 存储库,我想将其中一些设置为只读以防止更多推送。有些人有指向这些存储库的遥控器。
这些裸存储库已初始化--shared=group
,因此将所有文件的文件权限设置为 660 是否足以仍然允许 SSH 访问,但不允许写入?或者有没有更简单的方法?
干杯。