当我创建一个数据流块时,我指定它的.MaxDegreeOfParallelerism如下:
...New ExecutionDataflowBlockOptions With
{.MaxDegreeOfParallelism = System.Environment.ProcessorCount - 1}...
Run Code Online (Sandbox Code Playgroud)
以后有什么方法可以改变吗?
在XAML中,DataGrid绑定到一个名为EF实体的列表Results
.一列被绑定到Count
的Buildings
导航属性.延迟加载已关闭.所以我需要包含Buildings
在查询中,以获得它的数量.这会导致性能问题,因为整个Buildings
实体集合会在内存中加载.但我只需要Count
它.有没有办法获得Count
导航属性而不将其加载到内存中?
var resQuery =
db.BAStreets
.Include("Street.StreetType")
.Include("Area.District")
.Include("Buildings")
.Where(x => true);
Results = resQuery.ToList();
Run Code Online (Sandbox Code Playgroud)
在XAML中绑定:
<DataGridTextColumn Binding="{Binding Buildings.Count}"/>
Run Code Online (Sandbox Code Playgroud)
还有一点其他问题.我用它:.Where(x => true)
将DbSet强制转换为IQueryable.看起来这是一种气味的东西.什么是标准模式?
c# xaml entity-framework eager-loading navigation-properties
例如ISomething
,一个具有三个属性的接口:string Name
和int Count
一些复杂的属性ImComplex
(具有循环依赖性等),我不想自动构建.所以我需要AutoFixture来创建一个Mock of ISomething
with Name
并Count
通过其默认算法设置并ImComplex
为null.但如果我试图像这样解决它我会得到一个例外:
fixture.Customize(new AutoConfiguredMoqCustomization());
var some = fixture.Build<ISomething>().Without(x=>x.ImComplex).Create<ISomething>();
Run Code Online (Sandbox Code Playgroud)
Ploeh.AutoFixture.ObjectCreationException:装饰的ISpecimenBuilder无法根据请求创建样本:RP.Core.IInformationUnit.如果请求表示接口或抽象类,则会发生这种情况; 如果是这种情况,请注册一个可以根据请求创建标本的ISpecimenBuilder.如果在强类型的Build表达式中发生这种情况,请尝试使用其中一个IFactoryComposer方法提供工厂.
我该怎么办?
.NET Core SDK 在 Windows Server 2016dotnet
命令上更新到 2.1.4 后消失了。指令:
dotnet --info
'dotnet' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
我试图在下面的示例中获取异常堆栈跟踪的最内部方法名称。由于未知的原因,我总是得到MoveNext
方法名称,而不是真实姓名。我该如何解决?
var st = new StackTrace(ex, true);
var frame = st.GetFrames()?.First(y => y.GetFileName() != null);
var method = frame.GetMethod().ToString(); // result: Void MoveNext()
var method2 = frame.Name; // result: MoveNext
Run Code Online (Sandbox Code Playgroud)
更新:
TPL Dataflow
当块的委托中抛出异常时就会发生这种情况:
private async Task Parse(ListItem item)
{
await Task.Delay(1);
throw new Exception("Error");
}
Run Code Online (Sandbox Code Playgroud)
//...
var parseBlock = new ActionBlock<ListItem>(
async x => { await Parse(x).ConfigureAwait(false); });
Run Code Online (Sandbox Code Playgroud)
MoveNext
我从任何区块与任何代表一起得到。堆栈跟踪:
at RP.Core.ListsPipeline.<Parse>d__21.MoveNext() in Class.cs:line 179
--- End of stack trace from previous location where exception was thrown …
Run Code Online (Sandbox Code Playgroud) 有没有办法让同一个集群中的多个不同的SF服务监听同一个端点http 80?服务的 WebAPI 具有不同的路由。
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="80" />
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
无法绑定到地址http://[::]:80 : 地址已被使用。
有没有办法避免这种情况?
http endpoint azure-service-fabric asp.net-core asp.net-core-webapi
@Hallgrim在这里找到了CodeDom 的这种方法:
private static string ToLiteral(string input)
{
using (var writer = new StringWriter())
{
using (var provider = CodeDomProvider.CreateProvider("CSharp"))
{
provider.GenerateCodeFromExpression(new CodePrimitiveExpression(input), writer, null);
return writer.ToString();
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我们需要对 .NET Core 进行 Roslyn 重制。或者我们应该手动替换符号?
我有一张Dog
桌子.每只狗Breed
都有0到2张照片.我需要收到每个品种的所有狗的照片数:表BreedId
和匹配PhotosCount
.所以结果表应该是:
BreedID|PhotosCount
-------------------
1 |3
-------------------
2 |1
-------------------
Run Code Online (Sandbox Code Playgroud)
c# ×5
.net ×2
.net-core ×1
asp.net-core ×1
async-await ×1
autofixture ×1
automoq ×1
cmd ×1
converters ×1
endpoint ×1
exception ×1
http ×1
interface ×1
literals ×1
methods ×1
moq ×1
roslyn ×1
sql ×1
sql-server ×1
string ×1
t-sql ×1
tpl-dataflow ×1
xaml ×1