小编mah*_*hdi的帖子

该属性是键的一部分,因此无法修改或标记为已修改(ForeignKey 不是键)

我有两个没有键关系的实体,当我想编辑人员中的人员代码字段时,会向我显示此错误。 'The property 'Personnel.PersonnelCode' is part of a key and so cannot be modified or marked as modified. To change the principal of an existing entity with an identifying foreign key, first delete the dependent and invoke 'SaveChanges', and then associate the dependent with the new principal.' EnrolNumberPersonnelNum 表也没有与我的表中更改的人员记录有关系的记录

人员等级

public class Personnel : BaseEntity, IBaseEntityTypeConfiguration<Personnel>
    {
        public Personnel()
        {
            EnrolNumberPersonnelNums = new HashSet<EnrolNumberPersonnelNum>();
        }
        [Key]
        public int PersonnelId { get; set; }
        public string PersonnelCode { get; set; } …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework entity-framework-core ef-core-6.0

9
推荐指数
1
解决办法
2万
查看次数

回复消息电报机器人

我知道如何回复用户的消息,但不知道如何回复机器人发出的最新消息。

我需要机器人MessageID

来自用户的这条消息:嗨,这是一条发送给用户的消息:

await BotAdminChannel.SendTextMessageAsync(e.Message.Chat.Id, "hello user");
Run Code Online (Sandbox Code Playgroud)

这是用户的回复消息:

await BotAdminChannel.SendTextMessageAsync(358434970, "How are you user", replyToMessageId:e.Message.MessageId);
Run Code Online (Sandbox Code Playgroud)

但我想回复你好用户,我需要 bot_messageID 吗?怎么才能得到它

class Program
{
    private static ITelegramBotClient BotAdminChannel = new TelegramBotClient("token");
    static void Main(string[] args)
    {
        BotAdminChannel.OnMessage += BotAdminChannel_OnMessage;
        Console.Title = BotAdminChannel.GetMeAsync().Result.FirstName;
        BotAdminChannel.StartReceiving();
        Console.ReadLine();
    }

    private async static void BotAdminChannel_OnMessage(object sender, MessageEventArgs e)
    {
        await BotAdminChannel.SendTextMessageAsync(e.Message.Chat.Id, "hello user");
        await BotAdminChannel.SendTextMessageAsync(358434970, "How are you user", replyToMessageId:e.Message.MessageId);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# telegram-bot

5
推荐指数
1
解决办法
2万
查看次数

未找到:'Void CoreTypeMappingParameters..ctor

我将项目从 ef 6 更新到 7 并收到此错误

not found: 'Void CoreTypeMappingParameters..ctor(System.Type, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer, System.Func`3<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator>)'.
  Source=EntityFrameworkCore.SqlServer.HierarchyId
Run Code Online (Sandbox Code Playgroud)

entity-framework hierarchyid entity-framework-core ef-core-7.0

5
推荐指数
1
解决办法
2892
查看次数