如果一个库(例如,在github上)没有通过nuget包发布自己,我必须手动将其作为参考包含,对吗?我看到很多关于如何为Visual Studio添加项目引用的参考文章,但我似乎无法弄清楚如何在Visual Studio Code上做到这一点.
在这种情况下,我已经下载了库的zip,并将展开的文件夹移动到我的项目中,然后尝试了using <namespace>,这不起作用.
编辑:
我注意到这个下载的zip包含了一个.nuspec.我可以用这个文件扩展名来导入它在我的项目中吗?
我的eta值是OffsetDateTime,我有一个DateDate类型的scheduledDate.如果没有设置eta,我想回到日期.
这个日期的一个例子是Tue Jul 21 10:32:28 PDT 2020.要转换这个问题,我想这样做:
OffsetDateTime.ofInstant(dto.getScheduledTime().ToInstant(), ZoneOffset.UTC)
感觉就像UTC偏移量是错误的,因为日期中有PDT了,但同时这也是不喜欢"美国/洛杉矶"一timezoneId.
我对如何处理这个问题感到有些困惑.
我向现有的 SQL Server 数据库添加了一个新表。我使用它生成的 id 作为密钥。我运行了dotnet ef migration add NewTable,运行没有错误。我查看了迁移文件,这是为我的新表添加的内容:
migrationBuilder.CreateTable(
name: "InboxNotifications",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
DataId = table.Column<string>(type: "nvarchar(max)", nullable: true),
EventIdent = table.Column<string>(type: "nvarchar(max)", nullable: true),
Message = table.Column<string>(type: "nvarchar(max)", nullable: true),
Status = table.Column<int>(type: "int", nullable: false),
TeamIdent = table.Column<string>(type: "nvarchar(max)", nullable: true),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Type = table.Column<int>(type: "int", nullable: false), …Run Code Online (Sandbox Code Playgroud) 我有一个 .NET CORE 2 后端。在我的一个控制器端点中,我正在创建要通过电子邮件发送的邀请。这似乎是端点上的一个巨大瓶颈,考虑之后,我真的不需要等待这些邀请。如果电子邮件未能发送出去,我无论如何也无能为力。
如果我不这样做await sendFn(),它本质上会是一种即发即忘的方法吗?我正在阅读另一个 stackoverflow 线程,我必须这样做sendFn().ContinueWith(t => throw(t))才能捕获异常,因为它将在另一个线程中。
我在代码库周围有类似的邮件功能。他们每个人做的事情都略有不同,但是有没有我可以做的服务来包装这些东西,让它们着火而忘记?我认为有些地方我不能使用await(如果有效的话),但有些东西会改变数据库上下文,所以如果我不等待它们,我可能会遇到某些东西正在访问相同的数据库上下文的情况。
[HttpPost]
public async Task<IActionResult> CreateEvent([FromBody] Event val)
{
_ctx.Event.Add(val);
await _ctx.SaveChangesAsync();
await SendInvitations(val); // fn in question
return Ok();
}
public async Task SendInvitation(Event event)
{
forEach (var person in event.people)
{
await _ctx.Invitation.Add(person); // This shouldn't happen while another iteration or some other async code elsewhere is using the db ctx.
_ctx.SaveChangesAsync();
await _mailService.SendMail(person.email,"you have been invited"); // don't really need …Run Code Online (Sandbox Code Playgroud) 最近,我将.NET 1.1.4代码迁移到.NET 2.0.0。一切似乎都正常。现在,我尝试通过执行以下操作添加新的模型/表:
dotnet ef update
我得到以下异常:
DbInitializer失败!无法在“ ApplicationUser”上配置密钥,因为它是派生类型。密钥必须在根类型“ IdentityUser”上配置
我有一个扩展IdentityUser的ApplicationUser和扩展IdentityRole的ApplicationRole,这是其他一些教程/ stackoverflow帖子所说的。
我不确定我可能还会错过什么。
在我的ApplicationUser类中,我有:
ICollection<IdentityUserRole<string>>
是否必须是像ApplicationUserRole这样的自定义类型?IdentityUserRole和IdentityRole有什么区别?
编辑:
我认为这可能是因为在我的context.cs文件中,OnModelCreating我有:
builder.Entity<ApplicationUser>()
.ToTable("AspNetUsers")
.HasKey(x => x.Id);
Run Code Online (Sandbox Code Playgroud)
这Id是继承自IdentityUser。
EDIT2:
所以我注释掉了这一行,该错误消失了。转到下一行,这基本上是相同的,但是对于我的ApplicationRole来说,它扩展了IdentityRole。我不太清楚这是什么意思。我是否需要覆盖id属性?
EDIT3:
好的,所以我将builder.Entity中的类型更改为IdentityUser和IdentityRole。为什么在我必须使用的startup.cs中ApplicationUser以及ApplicationRole调用时可以解决此问题services.AddIdentity<ApplicationUser, ApplicationRole>
我尝试使用 componentDidCatch,但看起来该钩子仅用于渲染组件中的实际错误。Promises 可以在组件层次结构之一中发生,但实际上直到稍后才会抛出。
我还在我的函数周围包裹了一个 tryCatch,它执行应用程序的初始渲染,但也未能捕获异常。(出于我认为的原因)
我正在关注本教程:https : //medium.com/flawless-app-stories/ios-remote-push-notifications-in-a-nutshell-d05f5ccac252
但是由于某种原因,我越来越
无法将“ AppDelegate”分配给“ UNUserNotificationCenterDelegate”。
那条线是做什么的?如果我将其注释掉,其余代码将正常工作,并且如果用户希望允许通知,则会提示用户。
func registerForPushNotifications() {
UNUserNotificationCenter.current().delegate = self // line in question
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
(granted, error) in
print("Permission granted: \(granted)")
// 1. Check if permission granted
guard granted else { return }
// 2. Attempt registration for remote notifications on the main thread
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
Run Code Online (Sandbox Code Playgroud) asp.net ×3
c# ×3
.net ×1
async-await ×1
asynchronous ×1
ios ×1
java ×1
java-date ×1
java-time ×1
javascript ×1
promise ×1
react-redux ×1
reactjs ×1
spring ×1
sql-server ×1
swift3 ×1
swxmlhash ×1
xcode9 ×1