为什么List<T>.IndexOf
允许超出范围的起始指数?
var list = new List<int>() { 100 };
Console.WriteLine(list.IndexOf(1/*item*/, 1/*start index*/));
Run Code Online (Sandbox Code Playgroud)
没有任何例外.但是1
这个系列中没有带索引的项目!只有一个带0
索引的项目.那么,为什么.Net
允许你这样做呢?
Android 中状态栏的默认色调是白色的(所以状态栏会变暗有点奇怪):
我发现我可以在大于或等于 23 的 Android 版本中更改色调。但后来我发现我的设备(Android 5.1,API 22)上的几个应用程序使用黑色色调。他们是怎么做到的?
更新: 这就是我的意思:其他一些应用程序有浅色状态栏和黑色图标、时间标签等。
这是我的带有白色状态栏的 App 示例:
我无法设置windowLightStatusBar
为 true 使其看起来像 API < 23 的设备中第一张图片中的应用程序。
我的 Postgres 数据库中有一些主表(如公司)和许多从属表(如 CompanyAddresses、CompanyPaymentInfos 等):
CREATE TABLE Companies (
Id uuid NOT NULL PRIMARY KEY,
...);
CREATE TABLE CompanyAddresses(
CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id),
...);
CREATE TABLE CompanyPaymentInfos(
CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id),
...);
Run Code Online (Sandbox Code Playgroud)
我在 C# 代码中使用标准库中的事务:
private TransactionScope GeTransactionScope()
{
return new TransactionScope(
TransactionScopeOption.RequiresNew,
new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadCommitted
},
TransactionScopeAsyncFlowOption.Enabled);
}
private async Task DoChange(...)
{
using (var scope = GeTransactionScope())
{
await Insert(Company);
await Task.WhenAll(
Insert(CompanyPaymentInfo),
Insert(CompanyAddress),
Insert(CompanyTags),
// so …
Run Code Online (Sandbox Code Playgroud) 在我的 SQL Server 表中,我有一个计算列。因此,对于该列,我希望在 Linq2DB 生成的代码中只包含读取语句(如“select”)而没有写入语句(如“update”)。
最简单的方法是什么?
我不希望所有更新/添加语句都显式地阻止写入此列。
c# ×3
.net ×2
android ×1
dapper ×1
linq2db ×1
list ×1
npgsql ×1
orm ×1
postgresql ×1
sql-server ×1