使用 Azure Table Storage
How to use Azure Blob Storage in .NET
MsDoc: Get started with Azure Table storage and the Azure Cosmos DB Table API using .NET
C# 轉換 Unix 的 Timestamp 為 DateTime 格式
Convert unix timestamp to datetime
StackOverflow: How can I convert a Unix timestamp to DateTime and vice versa?
使用 MongoDB + Azure CosmosDB 可能會遇到的五個坑
MongoDb + AzureCosmosDb 可能會遇到的五個大坑
TTL那個我已經遇到了QAQ
WILLOWTREE: Azure Cosmos DB Mongo API: 5 Things to Know Before You Migrate
移除 Git 的 SubModule
程式碼重構 Switch 很多的部分
Switch 好多想重構
Switch重構
C# .NET Research : C# Switch 重構 Refactoring 2 : 使用資料字典與多型或委派方法或 Lambda
使用 UnitOfWork 讓資料同時處理
在 Layer 層可以使用其他的 Repository 並不是獨佔
Layer 層別是可以使用其他 Repository 的
Github : Having a repository dependent on another repository
C# 在非同步方法中使用 ref/out
C# 在非同步 Method 中使用 ref/out
記起來 以後用的到
在 C# 异步方法中使用 out/ref 参数机制
C# Dictionary 使用 TryGetValue 實際上效能比 ContainsKey 還快
C# Dictionary TryGetValue is faster than ContainsKey
教你怎麼用 Dictionary
C# Example Page : TryGetValue
使用 WireMock 回傳假的 API Data
WireMock for ASP.NET Core
WireMock 是一個用來回傳假的 Api Data 的好東西
有機會再用
Github : MireMock Wiki
C# 取代 IF 的 Boolean Check 方式
C# 取代 if 內的 boolean check
有沒有想過為什麼 if (int)
當 int > 0 return true else return false
可以用 implicit operator bool
StackOverflow : implicit operator bool
JWT Token 若給認證錯誤 Error Class 也能接到
使 JWT Token 返回認證錯誤也用 Error Class 去包
先暫存個連結怕SLACK吃掉
Github : ruidfigueiredo
StackOverflow 的架構參考
根據不同的權重分配機率
權重分配機率
這篇介紹的很詳盡
我最後還是使用的數線型的
實測在我的程式內效能最好
Weighted Random Distribution
在 MongoDB Collection 內完全移除一個 Field
Remove mongodb field from collections
1 | { |
db.example.update({}, {$unset: {tags.words:1}}, false, true);
remove words
1 | { |
StackOverflow : How to remove a field completely from a MongoDB document?
CosmosDB 的 MongoDB 內如何實作 TTL (Time To Live)
CosmosDb MongoDb TTL Settings
就一個字 牛B
MicrosoftDocs : Expire data in Azure Cosmos DB MongoDB API
ASP.NET Core UserHttpsRedirection 無憑證無 Response 問題
ASP.NET Core 內在 app.UserHttpsRedirection() 後 Postman 打 沒反應的問題
此問題發生原因是在本機端沒有憑證用於Https,
可在自身專案內加入一個開發用的憑證,dotnet dev-certs https --help
醬子應該就可以用了
Configuring HTTPS in ASP.NET Core 2.1
Document Database Providers Update
MongoDb EntityFramework Provider 更新之後要改好多東西
- IList >> List
- BsonDateTime >> DateTime
強制要改,否則實體會炸開來,
最後
- List<string>不可用,出現
list<string> is not a supported primitive type or a valid entity type
原生的EntityFramework的限制的樣子
感謝鮑大人幫我找到解法
StackOverflow : How to persist a list of strings with Entity Framework Core?
利用 Entity Framework Core 2.1
的 Value Conversions
可解
比較之前的 EF 就只能 List property 掛個 [Notmapped]
然後配合用 Json.NET 或 Automapper 把顯示出來的和存起來的做轉換
- Dictionary<string, MyObject>也不可用,出現同3的錯誤
一樣利用 Value Conversions
可解
Jerrie Pelser : Store a Dictionary as a JSON string using EF Core 2.1
MongoDB C# Driver 的一些東西
MongoDB
MongoDb Host
MongoDb Index
EntityFrameworkCore MongoDb Provider
更新之後dbcontext都壞了
今天終於找到原因
我之前都用BsonDateTime
存日期
現在Provider改用DateTime
去存
然後就爆炸了
另一點是不能使用IList
做為宣告
1 | because it is of type 'IList<string>' which is not a supported primitive type or a valid entity type. |
List
似乎也是
1 | because it is of type 'List<string>' which is not a supported primitive type or a valid entity type. |
CosmosDB Setting for GeoLocation
好像直接用這個當 CosmosDB BravoPoint 設定即可
1 | { |
C# List Except 需要使用自訂的 IEqualityComparer 去比對
List.Except 使用 Custom Class 做比對
需要自定義 IEqualityComparer
不小心查到 LINQ Except 的 Source Code
Github : dotnet/corefx
MongoDB insert/update all data
MongoDB 的一些 Script
insert for all data
db.BravoEventPoints.update({}, {$set : {“StartTime” : new ISODate(“2012-01-10”)} }, {upsert:false, multi:true})
StackOverflow : Mongodb Add new field to every document
// update for all data
db.BravoEventPoints.update({}, {$set: {“EndTime” : null }}, {multi:true})
db.BravoEventPoints.updateMany({},{$set: {“StartTime” : null }})
StackOverflow : Mongodb update all
Azure CosmosDB 使用 MongoDB Geolocation
Azure CosmosDB 使用 MongoDB GeoLocation功能
真D好難
首先先到Azure CosmosDb 你的Collection設定內
將includedPaths改成
1 | { |
然後再用程式碼加入2dsphere的index
1 | IndexKeysDefinition<BravoPoint> keys = "{ Location: \"2dsphere\" }"; |
最後可以得出Result
1 | var gp = new GeoJsonPoint<GeoJson2DGeographicCoordinates> |