当我使用表达式树来替换方法(如Math.Max)时,它看起来像是在表达式树中成功替换它.但是当我在Entity Framework中使用它时,它抛出了一个关于不支持Entity Framework的Math.Max的异常.但我明确地取而代之.
有谁知道为什么?还有一种修复代码的方法吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace ConsoleApplication1
{
public static class CalculateDatabase
{
public static void Main(string[] args)
{
var calcs = GetCalculateToAmounts(GetTestItems(), 0.5m).ToList();
}
public static IQueryable<Item> GetTestItems()
{
var items = new List<Item>();
items.Add(new Item()
{
DoNotItem = true,
ReductionAmount = 2,
PreviousDiscountAmount = 3,
CurrentDiscountAmount = 10,
CurrentAmount = 100,
PreviousAmount = 50,
CurrentBillAmount = 75
});
return items.AsQueryable();
}
public class Item
{
public bool DoNotItem { get; set; …Run Code Online (Sandbox Code Playgroud) 此代码引发异常。如何在不将其存储在文件中的情况下验证 SSH 指纹?我相信下面的代码是为公钥设计的。但是带有 SFTP 服务器的客户端验证了指纹并且没有给我公钥。
import os
import shutil
import pysftp
import paramiko
connection_info = {
'server': "example.com",
'user': "user",
'passwd': "password",
'target_dir': "out/prod",
'hostkey': "ssh-rsa 2048 d8:4e:f1:f1:f1:f1:f1:f1:21:31:41:14:13:12:11:aa",
}
def move_files_from_server_to_local(server, localpath):
target_dir = server['target_dir']
keydata = "d8:4e:f1:f1:f1:f1:f1:f1:21:31:41:14:13:12:11:aa"
key = paramiko.RSAKey(data=decodebytes(keydata))
options = pysftp.CnOpts()
options.hostkeys.add('example.com', 'ssh-rsa', key)
with pysftp.Connection(
server['server'],
username=server['user'],
password=server['passwd'],
cnopts=options) as conn:
conn.get_d(target_dir, localpath)
delete_files_from_dir(conn, target_dir)
move_files_from_server_to_local(connection_info, "/")
Run Code Online (Sandbox Code Playgroud)
该代码基于使用 pysftp 验证主机密钥。