小编Den*_*eal的帖子

找不到方法:'Void CoreTypeMappingParameters..ctor(System.Type, Microsoft.EntityFrameworkCore.Storage.ValueConversion 错误

找不到方法:'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>)'。

我收到这个错误。我怎么解决这个问题?

visual-studio entity-framework-core

41
推荐指数
4
解决办法
4万
查看次数

MailKit.Security.AuthenticationException: '535: 5.7.139 身份验证失败,用户被组织的安全默认策略锁定

我正在尝试使用以下配置从我的 Office365 电子邮件帐户的 .Net 6 应用程序发送电子邮件

"EmailConfiguration": {
   "From": "XXXXXXXXXXX",
   "SmtpServer": "smtp.office365.com",
   "Port": 25, // tried port 587 also
   "Username": "XXXXXXXXX",
   "Password": "XXXXXXXX"
}
Run Code Online (Sandbox Code Playgroud)

这是我发送电子邮件的代码:

using var client = new SmtpClient();
try
{
    client.Connect(_emailConfig.SmtpServer, _emailConfig.Port, MailKit.Security.SecureSocketOptions.StartTls);
    //client.AuthenticationMechanisms.Remove("XOAUTH2");
    client.Authenticate(_emailConfig.UserName, _emailConfig.Password);

    client.Send(mailMessage);
}
catch
{
    //log an error message or throw an exception or both.
    throw;
}
finally
{
    client.Disconnect(true);
    client. Dispose();
}
Run Code Online (Sandbox Code Playgroud)

client.Authenticate但我在通话时收到此错误

MailKit.Security.AuthenticationException: '535: 5.7.139 身份验证失败,用户被组织的安全默认策略锁定。请联系您的管理员。[PN2PR01CA0027.INDPRD01.PROD.OUTLOOK.COM 2023-12-10T12:33:11.474Z 08DBF8259ECF3F85]'

我们尝试检查管理面板中的所有内容,以查看特定电子邮件帐户或用户是否被锁定,但我们没有发现类似情况。

我已使用以下命令Authenticated SMTP启用了该特定电子邮件帐户的设置

我也尝试禁用该设置,但随后我开始收到身份验证失败的错误。

有人可以指导我可能出了什么问题吗?

smtp smtpclient .net-6.0

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

测试单个对象是否与 Func&lt;T, bool&gt; 匹配

我有一个对象(数据库中的一条记录),想要检查该对象是否与Func<T, bool>.

我通过将对象添加到对象列表中解决了这个问题,并尝试使用 where 子句从该列表中获取它,给定这样的条件

var testMatch = new Test
{
    t1 = "123"
};

// Query is stored in a string and compiled with Sprint.Filter.OData to p => p.t1 == "123"
var query = "t1 eq '123'";
var compiledQuery = Filter.Deserialize<Test>(query).Compile();

// This works like expected
Console.WriteLine(Match<Test>(compiledQuery, testMatch));

public bool Match<T>(Func<T, bool> condition, T testObject)
{
    var test = new List<T>();
    test.Add(testObject);
    var t = test.Where(condition).FirstOrDefault();
    return (t != null);
}

public class Test
{
    public string …
Run Code Online (Sandbox Code Playgroud)

c#

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

将方法转换为 C# 中的泛型方法

如何将此方法转换为通用形式。由于对象的属性,我无法这样做。

private async Task<T> GetSalesforceMachineData<T>()
{
    T machineData = await CallSalesforceApi<T>();
    while (!machineData.done)
    {
        var encodedUrl = HttpUtility.UrlEncode(machineData.nextRecordsUrl);
        T nextData = await GetNextData<T>(encodedUrl);
        machineData.done = nextData.done; //not able to convert because of these properties
        machineData.nextRecordsUrl = nextData.nextRecordsUrl;//not able to convert because of these properties
        machineData.records.AddRange(nextData.records);//not able to convert because of these properties
    }
    return machineData;
}
Run Code Online (Sandbox Code Playgroud)

像这样的东西

private async Task<T> GetSalesforceMachineData<T>()
{
    T machineData = await CallSalesforceApi<T>();
    while (!machineData.done)
    {
        var encodedUrl = HttpUtility.UrlEncode(machineData.nextRecordsUrl);
        T nextData = await GetNextData<T>(encodedUrl);
        machineData.done …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net

0
推荐指数
1
解决办法
64
查看次数