当查询一个大型表时,你需要在代码中访问导航属性(我明确地不想使用延迟加载)什么会表现更好.Include()或.Load()?或者为什么要使用另一个?
在这个例子中,包含的表只有大约10个条目,员工有大约200个条目,并且可能发生大多数这些条目将被加载,因为它们匹配where子句.
Context.Measurements.Include(m => m.Product)
.Include(m => m.ProductVersion)
.Include(m => m.Line)
.Include(m => m.MeasureEmployee)
.Include(m => m.MeasurementType)
.Where(m => m.MeasurementTime >= DateTime.Now.AddDays(-1))
.ToList();
Run Code Online (Sandbox Code Playgroud)
要么
Context.Products.Load();
Context.ProductVersions.Load();
Context.Lines.Load();
Context.Employees.Load();
Context.MeasurementType.Load();
Context.Measurements.Where(m => m.MeasurementTime >= DateTime.Now.AddDays(-1))
.ToList();
Run Code Online (Sandbox Code Playgroud) 我对以下查询存在严重问题.
context.CharacteristicMeasures
.FirstOrDefault(cm => cm.Charge == null &&
cm.Characteristic != null &&
cm.Characteristic.Id == c.Id &&
cm.Line != null &&
cm.Line.Id == newLine.Id &&
cm.ShiftIndex != null &&
cm.ShiftIndex.Id == actShiftIndex.Id &&
(newAreaItem == null ||
(cm.AreaItem != null &&
cm.AreaItem.Id == newAreaItem.Id)));
Run Code Online (Sandbox Code Playgroud)
TargetException: Non-static method requires a target 当newAreaItem为null时,我得到一个.如果newAreaItem不为null,我得到一个NotSupportedException: Unable to create a constant value of type 'PQS.Model.AreaItem'. Only primitive types or enumeration types are supported in this context.
我已经检查过它们是否为null:c,newLine,actShiftIndex所有3个变量都不为空且可以访问Id.
我不明白......请帮忙.
如果你需要更多信息..不要犹豫,问...
UPDATE
我可以消除NotSupportedException,但是当newAreaItemIsNull为true时我仍然得到了TargetException ..:/
bool …Run Code Online (Sandbox Code Playgroud) 我们使用多个svg符号来显示图标.
<!-- defining them at the start of the page -->
<div id="icon-container">
<svg xmlns="http://www.w3.org/2000/svg">
<symbol xmlns="http://www.w3.org/2000/svg"
id="rect" ...>
<rect... />
</symbol>
<symbol xmlns="http://www.w3.org/2000/svg"
id="circle" ...>
<circle... />
</symbol>
</svg>
</div>
<!-- using them in the page somewhere -->
<svg>
<use xlink:href="#rect"></use>
</svg>
Run Code Online (Sandbox Code Playgroud)
在某些情况下,我们需要稍后用另一个图标替换它们(比如在折叠控件上),因此我创建了一个小帮助函数来更改xlink:href为新的符号名称.
$.fn.replaceSVGIcon = function(id) {
$(this).find('svg')
.andSelf()
.filter('svg')
.find('use')
.attr('xlink:href', '#' + id);
}
Run Code Online (Sandbox Code Playgroud)
这适用于除Windows 7上的IE10 + IE11之外的所有浏览器(但奇怪的是它适用于Windows 8).
当你在IE11中打开下面的片段并点击红色框时,一切都很好,但是一旦你开始点击其中的元素,它就会在第一次更改图标后打破整个页面.
(function($){
$.fn.replaceSVGIcon = function(id) {
$(this).find('svg').andSelf().filter('svg').find('use').attr('xlink:href', '#' + id);
}
})(jQuery);
clickFunction = …Run Code Online (Sandbox Code Playgroud)我正在尝试使用一个svg元素,该元素在flexbox中使用容器大小调整大小,但由于某种原因,它会混淆svg下面的div(带文本)的大小.(调整浏览器窗口大小时会有多少更改)

以下是我用于所有这些的基本css属性:
[layout] {
box-sizing: border-box;
display: flex;
}
[layout=column] {
flex-direction: column;
}
[layout=row] {
flex-direction: row;
}
[flex] {
box-sizing: border-box;
flex: 1;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="content" style="height: 100%;" layout="row">
<div class="card" layout="column" flex>
<div class="toolbar" layout="column">
<span>Test</span>
</div>
<div class="card-content" layout="column" flex>
<div layout="column" flex>
<div layout="column" flex>
<div layout="column" flex
style="background:green;">
<svg viewBox="0 0 50 50">
<circle r="25" cx="25" cy="25">
</svg>
</div>
</div>
<div>Text</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Codepen: http ://codepen.io/anon/pen/rVJepm
如何在使用SVG时修复尺寸?
我在C#中有一个非常简单的Azure函数,已经为其设置了Azure AD Auth。我刚刚使用Express设置在Function配置中创建了App注册。
public static class IsAuthenticated
{
[FunctionName("IsAuthenticated")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "options", Route = null)]
HttpRequest req,
ILogger log)
{
return new OkObjectResult("You are " + req.HttpContext.User.Identity.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中访问该函数时,一切都会按预期进行(如果未登录,则必须登录并重定向到我的API)。但是,如果我在任何需要Bearer令牌的地方尝试访问我的函数,都会收到401 Unauthorized错误消息。即使很奇怪,我也无法在Azure门户中执行该功能。

但是获取令牌没有问题,并将其添加到请求中:
我已经尝试了一些其他方法来解决此问题。首先,我认为这可能是CORS问题(因为我也有一些问题),只是将CORS设置为接受*,但没有任何变化。
然后,我将我的API登录端点添加到了重定向中,并尝试将隐式授予设置为也接受Access令牌,但它仍然无法正常工作。
有什么我忽略的吗?App Registration Express配置不应该只与Azure函数一起使用吗?
编辑:
按照@ thomas-schreiter的建议,将URL放入功能应用程序的重定向中没有做任何更改(我已经尝试了屏幕截图中的配置,也只是将每个值单独放置了)。
编辑2:
我现在也尝试用Postman手动方式获取Bearer令牌,但是在调用API时仍然遇到401。
我想在WPF中创建一个null顶部有一个项目的ComboBox,当选中此项时,SelectedItem应设置为null(重置为默认状态).我一直在搜索,但没有找到令人满意的解决方案.
如果可能的话,我希望它只使用XAML代码或附加行为,因为我不喜欢在ViewModel中更改View或覆盖标准控件.
这是我到目前为止提出的(缩短代码):
[...]
<Popup x:Name="PART_Popup" [...]>
<Border x:Name="PopupBorder" [...]>
<ScrollViewer x:Name="DropDownScrollViewer" [...]>
<StackPanel [...]>
<ComboBoxItem>(None)</ComboBoxItem>
<ItemsPresenter x:Name="ItemsPresenter"/>
</StackPanel>
</ScrollViewer>
</Border>
</Popup>
[...]
Run Code Online (Sandbox Code Playgroud)

我认为最好的办法就是以某种方式添加一个事件触发器,设置SelectedIndex到-1当项目被选中,但这里是我卡住了.
任何想法如何做到这一点?或者更好的方式,如附加行为?
我正在将该System.Windows.Controls.Ribbon库用于我的应用程序.一切都工作得非常好,除非我最大化窗口它开始离开屏幕.
我也注意到使用其他WPF应用程序但是当你使用RibbonWindow它时会变得更糟.

这是我的源代码(我认为没什么好激动的):
<RibbonWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
Title="TestWindow" Height="350" Width="525" Background="LightSteelBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Ribbon Grid.Row="0">
<RibbonTab x:Name="TestRibbon" Header="TestRibbon">
<RibbonGroup>
<RibbonButton x:Name="TestButton" Label="Button" LargeImageSource="traffic_lights_green.png" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
<ContentControl Grid.Row="1">
</ContentControl>
</Grid>
</RibbonWindow>
Run Code Online (Sandbox Code Playgroud)
有没有办法阻止窗口这样做?
当我尝试使用以下代码获取IE或Firefox的元素的整个字体样式时,我只得到一个空的结果,但是使用Chrome和Opera,我得到"normal normal bold normal 20px/normal arial"了我所期望的.
<!-- HTML -->
<div id="test" style="font: bold 20px arial; color: red;">test</div>
// JS
alert($('#test').css('font'));
Run Code Online (Sandbox Code Playgroud)
Wyh会发生这种情况,如何获得完整的字体属性呢?
FIDDLE:http: //jsfiddle.net/mwj12xkv/
我正在尝试从我的数据库加载数据,这需要 5-10 秒,但我希望 GUI 保持响应并且它应该是可取消的。
private CancellationTokenSource _source;
public IEnumerable<Measurement> Measurements { get { ... } set { ... } }
private async void LoadData()
{
_source = new CancellationTokenSource();
using (var context = new TraceContext())
{
Measurements = null;
Measurements = await context.Measurements.ToListAsync(_source.Token);
}
}
private void Cancel()
{
if (_source != null)
_source.Cancel();
}
public RelayCommand ReloadCommand
{
get { return _reloadCommand ?? (_reloadCommand = new RelayCommand(Reload)); }
}
private RelayCommand _reloadCommand;
public …Run Code Online (Sandbox Code Playgroud) 在我们的项目中,我们有ResourceDictionary一些看起来像这样的图标:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas x:Key="Icon.Refresh"
x:Shared="False"
Width="32"
Height="32"
Clip="F1 M 0,0L 32,0L 32,32L 0,32L 0,0">
<Path .../>
<Path .../>
<Path .../>
</Canvas>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
该x:Shared="False"属性是必需的,因为当我在多个视图中使用它时,图标将消失.
现在我们想要创建具有相同图标的另一个项目,因此我们决定将它们放在由两个项目引用的库项目中.
但是当我们尝试运行应用程序时,我们总是得到错误:
命名空间" http://schemas.microsoft.com/winfx/2006/xaml "中的共享属性只能在已编译的资源字典中使用."
但我们无法摆脱x:Shared="False"属性,因为据我所知,这是阻止图标消失的唯一方法.
那么我们可以做什么,通过项目参考和不消失的图标在多个项目上共享图标?