我需要解析一个表达式来获取一个sql where子句.
.NET FX中是否有任何类或任何已具备此功能的第三方库?
我的意思是Linq2SQL,EntityFramework,所有这些都必须这样做,所以有人知道,如果有什么可以重复使用而不是重新发明轮子?
MyType.Where(Func<TEntity,bool>((entity)=>entity.Id == 5)))
Run Code Online (Sandbox Code Playgroud)
现在我需要获取表示where子句的相应字符串:
where abc.Id = "5"
Run Code Online (Sandbox Code Playgroud)
这只是一个简单的例子.它也应该与逻辑连词一起使用.
我知道我可以创建表达式树并自己解析它,但我认为可能存在已经存在的东西,我错过了
当我使用ServiceStack创建服务时,他们可以轻松地测试何时只是实例化类并运行我的单元测试.
但是使用这种方法,验证器不会触发,因为运行时绑定它们并且在调用serivce之前它们是triggert.
我是否必须使用正在运行的服务进行IntegrationTests?或者有更聪明的方式吗?
在我的 System ni 中将 MongoDb 升级到 2.6.1 后,有时会出现以下错误:
遗留点超出球形查询范围
错误代码 17444
在这里:https : //github.com/mongodb/mongo/blob/master/src/mongo/db/geo/geoquery.cpp#L73 我可以看到这是由 mongo db 由于某些无效数据引起的。
// The user-provided point can be flat. We need to make sure that it's in bounds.
if (isNearSphere) {
uassert(17444,
"Legacy point is out of bounds for spherical query",
centroid.flatUpgradedToSphere || (SPHERE == centroid.crs));
}
Run Code Online (Sandbox Code Playgroud)
但目前我无法弄清楚为什么以及如何防止它。
我的代码如下所示:
IEnumerable<BsonValue> cids = companyIds.ToBsonValueArray();
return Collection.Find(
Query.And(
Query.In("CompanyId", cids),
Query.Near("Location", location.Geography.Longitude, location.Geography.Latitude, location.Radius / 6371000, true))).ToList();
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
QueryFailure 标志是传统点超出球形查询范围(响应为 {“$err”:“传统点超出球形查询范围”,“代码”:17444})。在 MongoDB.Driver.Internal.MongoReplyMessage
1.ReadFrom(BsonBuffer buffer, IBsonSerializationOptions …
我正在将数据发送到带有 webhook 集成的松弛通道。但是当我包含换行符 (\n) 时,我得到了 http 500。当我对换行符进行 url 编码时,我看到的是编码值,而不是 slacn 中的真正换行符
string body = "foo"
if(!string.IsNullOrWhiteSpace(feedEntry.Link ))
{
body += " \n <" + feedEntry.Link +">";
}
body = "{\"text\": \"" + body+ "\"}";
using(var client = new HttpClient())
{
var msg = new StringContent(body);
var result = await client.PostAsync(url, msg);
}
Run Code Online (Sandbox Code Playgroud) 鉴于:
使用简单的语法walker我想访问trivias(确切地说是EndOfLineTrivia)
public sealed class MyWalker : SyntaxWalker
{
public int Lines { get; set; }
public int Trivia { get; set; }
public int Node { get; set; }
public override void Visit(SyntaxNode node)
{
Node++;
base.Visit(node);
}
protected override void VisitTrivia(SyntaxTrivia trivia)
{
Trivia++;
base.VisitTrivia(trivia);
}
}
Run Code Online (Sandbox Code Playgroud)
我这样叫沃克:
SyntaxTree node = CSharpSyntaxTree.ParseText(sourceCode);
var root = node.GetRoot();
var walker = new LocWalker();
Run Code Online (Sandbox Code Playgroud)
问题
永远不会调用重写的VisitTrivia方法.
我们使用EWS托管API将我们的CRM与Exchange-Server同步.只要我使用EWS Mangage API 1.1,一切都很完美.现在我更新到Api 2.0(Dll-version:15.0.516.14)并且如果我从不同的线程绑定到同一个文件夹并且不明白原因,我会收到ArgumentException.
这是一个引发异常的示例代码:
private void TestAsyncFolderGet()
{
try
{
ExchangeService service = this.GetService();
Parallel.For(0, 20, (i) =>
{
Folder fo = Folder.Bind(service, WellKnownFolderName.Inbox);
});
}
catch (Exception ex)
{
this.State = "Failed: " + ex.Message;
}
}
private ExchangeService GetService()
{
ExchangeService result = new ExchangeService(ExchangeVersion.Exchange2010);
result.AutodiscoverUrl("test@foo.com");
return result;
}
Run Code Online (Sandbox Code Playgroud)
我的真实场景是我使用pullsubscription更改项目并处理更改异步.在这样做时,我绑定到父文件夹以获取一些信息.
任何人都可以帮我避免异常吗?
Stacktrace和异常信息:
System.ArgumentException:已添加具有相同键的项.
在System.Collections.Generic.Dictionary 2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.Exchange.WebServices.Data.ExchangeServiceBase.SaveHttpResponseHeaders(WebHeaderCollection headers)
at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse response)
at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalFindFolders(IEnumerable1 parentFolderIds,SearchFilter searchFilter,FolderView视图,ServiceErrorHandling errorHandlingMode)在Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(FolderId parentFolderId,FolderView视图)
我有一个带有德语变音符号(下面的saml)的xaml现在当我尝试解析它时,我得到一个invalidchar错误.
当我不使用XamlParser Context时,它可以工作.但我必须使用它来设置一些类型映射
XAML:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:test="clr-namespace:BR.UI.Tests.Items;assembly=BR.UI.ViewLocator.Tests"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
<UserControl.DataContext>
<test:SampleViewModel />
</UserControl.DataContext>
<Grid>
<Label>ö</Label>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
解析它的代码
var context = new ParserContext();
var result = System.Windows.Markup.XamlReader.Parse(xaml,context);
Run Code Online (Sandbox Code Playgroud)
我找不到任何设置编码提示(这将是.net字符串UTF-16)我做错了什么?
我还尝试使用XmlParserContext注入编码.
var xmlcontext = new XmlParserContext(null, null, null, XmlSpace.Preserve,
Encoding.Unicode);
var context = new ParserContext(xmlcontext);
Run Code Online (Sandbox Code Playgroud)
但它没有帮助:-(
我需要做什么?有某种XAML编码吗?
我创建了一个新的空的asp核心项目.我添加了一个简单的ts文件.
现在默认情况下它会自动编译为javascript.
在asp核心之前,项目对话框中有一个选项.但目前的核心解决方案中没有项目对话框.
我也试过这篇文章中描述的内容.所以我添加<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>到xproj文件的firest属性组,但它没有改变任何东西.
前段时间我安装了typescript完整包可能与此相关吗?
关于如何阻止visual studio在核心应用程序中自动打包typescript文件的任何建议?
xProj现在看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<!-- Makes the TypeScript compilation task a no-op -->
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>43a95da8-804b-459b-8082-fdceb957a8d2</ProjectGuid>
<RootNamespace>GulpTs</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<DnxInvisibleContent Include="bower.json" />
<DnxInvisibleContent Include=".bowerrc" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" /> …Run Code Online (Sandbox Code Playgroud) 在一个小的PowerShell构建脚本中,我构建并测试了一个.NET应用程序.
我现在想要在测试导致一个或多个失败时阻止脚本中的进一步步骤.
我试着像这样得到测试的结果:
$exitcode = dotnet test .\Domain.Tests
Write-Host "result $exitcode"
Run Code Online (Sandbox Code Playgroud)
但遗憾的是它没有返回退出代码表示成功我只是得到了测试测试说明.
有没有更好的方法然后解析失败的测试计数的字符串输出?
对于某些 API 集成,我有一个操作,需要添加两个字节并得到一个字节作为结果。这是某种校验和。现在本质上可能会发生溢出。
例如
byte a = 0xff
byte b = 0x01
byte results = a + b;
Run Code Online (Sandbox Code Playgroud)
是否有一个简单的内置语法来避免溢出以移动到下一个字节,或者我是否必须自己执行此操作?例如减去完整字节等等?没有找到相关的 API,我是否忽略了什么?
c# ×5
.net ×2
.net-core ×1
algorithm ×1
asp.net-core ×1
byte ×1
dotnet-test ×1
encoding ×1
linq ×1
mongodb ×1
parsing ×1
powershell ×1
roslyn ×1
servicestack ×1
slack-api ×1
sql ×1
string ×1
typescript ×1
wpf ×1
xamlreader ×1