尝试遵循文档,我无法使其工作.使用键字符串键入KeyedCollection.
如何在KeyedCollection中使字符串键不区分大小写?
在Dictionary上只能在ctor中传递StringComparer.OrdinalIgnoreCase.
private static WordDefKeyed wordDefKeyed = new WordDefKeyed(StringComparer.OrdinalIgnoreCase); // this fails
public class WordDefKeyed : KeyedCollection<string, WordDef>
{
// The parameterless constructor of the base class creates a
// KeyedCollection with an internal dictionary. For this code
// example, no other constructors are exposed.
//
public WordDefKeyed() : base() { }
public WordDefKeyed(IEqualityComparer<string> comparer)
: base(comparer)
{
// what do I do here???????
}
// This is the only method that absolutely must be overridden,
// because without …Run Code Online (Sandbox Code Playgroud) 无法弄清楚如何使用多个CTE
这失败了
; with [cteOne] as (
select 1 as col
),
[cteTwo] as (
select 2 as col
)
select 'yesA' where exists (select * from [cteOne])
select 'yexB' where exists (select * from [cteTwo])
Run Code Online (Sandbox Code Playgroud)
这有效 - 但这不是我需要的
; with [cteOne] as (
select 1 as col
),
[cteTwo] as (
select 2 as col
)
select * from [cteOne]
union
select * from [cteTwo]
Run Code Online (Sandbox Code Playgroud)
真正的语法是row_number()分区的连接
我刚刚使用派生表
XpsDocument是从磁盘加载的
通过XpsDocument.GetFixedDocumentSequence方法()创建一个FixedDocumentSequence
通过DocumentViewer显示
想添加添加页眉和页脚打印
我不需要将页眉和页脚添加回XPS文档 - 仅打印输出
我尝试实现DocumentPaginator但无法使大小调整或放置工作
与FlowDocument的这个页脚不一样
我在那里使用FlowDocuments的解决方案就好了
将XAML流文档转换为带样式的XPS
在FixedDocumentSequence上,大小调整来自文档(我猜)
例如可以混合横向和纵向
我无法弄清楚如何挂钩到大小调整并为页眉和页脚腾出空间
我可以在其上标记一个标题但它超过顶部页面
和横向页面被切断
无法分配每页当它来自一个文档序列
作为链接说,它是建议的页面大小
DocumentPage .Size是只读
即使我使用DocumentPaginator.GetPage加载页面时创建我想要的大小的DocumentPage,然后大小被覆盖
更糟糕的是,DocumentPaginator似乎没有正确地意识到尺寸,因为它没有正确处理混合风景和肖像.风景是打印的肖像,只是在页面上运行.
有人问我发布代码
也可能是一个更简单更好的方法
看看页脚到FlowDocument如何使用它
这是它破坏
//这从GetPage获取页面大小 - 忽略上面的大小
public class DocumentPaginatorWrapperXPS : DocumentPaginator
{
System.Windows.Size m_PageSize;
System.Windows.Size m_Margin;
DocumentPaginator m_Paginator;
FixedDocumentSequence fixedDocumentSequence;
Typeface m_Typeface;
private string printHeader;
private int? sID;
private string docID;
public DocumentPaginatorWrapperXPS(FixedDocumentSequence FixedDocumentSequence, System.Windows.Size margin, string PrintHeader, …Run Code Online (Sandbox Code Playgroud) 我无法在列表框中设置所选项目的背景颜色.我不想在这个例子中交替颜色.我把它们作为测试,他们工作.触发器IsSelected随着字体粗体变为粗体而前景变为红色而触发.将高亮颜色画笔设置为SteelBlue无法达到预期效果,因为当ListBox失去焦点时它会消失.当ListBox失去焦点并且是我想要的时候,红色和粗体确实成立.我想要为所选项目拍摄并保持背景颜色.现在,所选项目的背景为白色,并在ListBox失去焦点时保持不变.感谢您的帮助,我将测试任何建议的修复程序.
<ListBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Name="WFEnum" Visibility="Visible" BorderThickness="2" Margin="1" Padding="2,2,7,2"
ItemsSource="{Binding Path=SearchItem.SrchWorkFlows}" HorizontalAlignment="Left"
PresentationTraceSources.TraceLevel="High" AlternationCount="2" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="LightGreen"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="LightPink"></Setter>
</Trigger>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Background" Value="SteelBlue" />
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
</Style.Resources>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" Background="Transparent" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud) 无法绑定CollectionViewSource
DocProps是一个公共财产
public ObservableCollection<DocProp> DocProps1
Run Code Online (Sandbox Code Playgroud)
DataContext是自我的
DataContext="{Binding RelativeSource={RelativeSource self}}"
Run Code Online (Sandbox Code Playgroud)
这有效
<ListBox Grid.Row="0" Grid.Column="0" ItemsSource="{Binding Path=DocProps1}">
Run Code Online (Sandbox Code Playgroud)
我无法连接CollectionViewSource进行排序这甚至没有得到DocProps1
<ListBox Grid.Row="0" Grid.Column="0">
<ListBox.ItemsSource>
<Binding>
<Binding.Source>
<CollectionViewSource Source="{Binding Path=DocProps1}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Name" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Binding.Source>
</Binding>
</ListBox.ItemsSource>
Run Code Online (Sandbox Code Playgroud)
如何将CollectionViewSource绑定到公共属性?
谢谢
这是否有一个简短的手?
是否有匹配任何或null的通配符?
另一个是说它在零或一个匹配.
select [id], [word] from [FTSwordDef]
where [word] like 'system_'
or [word] like 'system'
Run Code Online (Sandbox Code Playgroud) 可以使用{}将值加载到Dictionary中吗?
这失败了
static Dictionary<byte, byte> dict = new Dictionary<byte, byte>() { new KeyValuePair<byte, byte>(1, 1) };
Run Code Online (Sandbox Code Playgroud)
这不会失败所以我怀疑在{}中有加载语法
static Dictionary<byte, byte> dic1252expand = new Dictionary<byte, byte>() { };
Run Code Online (Sandbox Code Playgroud)
这是有效的示例语法
byte[] bytes = new byte[] { 1, 2, 3 };
KeyValuePair<byte, byte> kvp = new KeyValuePair<byte, byte>(1, 1);
Run Code Online (Sandbox Code Playgroud) 使用FOR XML的SQL命令将单个长XML作为SqlString返回.我的问题是将长XML字符串读入.NET C#.
以下仅读取前2033个字符
SqlDataReader rdr = command.ExecuteReader();
if (rdr.HasRows)
{
rdr.Read();
Debug.WriteLine(rdr[0].ToString().Length.ToString());
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过command.ExecuteScalar和rdr.GetString,但仍然只获得前2033个字符.我已经更改了排序,它仍然在2033截断,所以它不太可能是由坏字符引起的.尝试rdr.GetSqlXml并获取错误消息无法将SqlString强制转换为SqlCachedBuffer.
如果我限制SQL返回少于2033个字符,我会得到完整有效的XML.所以我不认为这是一个XML解析问题,而只是一个截断.我不需要任何XML解析 - 它是TSQL语句中的有效XML,我需要它作为字符串.
如何阅读完整的XML(作为文本)?
TSQL有效.
select top 10 docSVsys.sID, docSVsys.docID
, (select top 10 value + '; '
from docMVtext with (nolock) where docMVtext.sID = docSVsys.sID
and docMVtext.fieldID = '113'
order by value FOR XML PATH('') ) as [To]
from docSVsys with (nolock)
order by docSVsys.sID
for xml auto, root('documents')
Run Code Online (Sandbox Code Playgroud)
FOR XML PATH提供了我所需要的和快速的.我尝试了常规查询,然后使用Xdocument生成XML,但是性能非常糟糕,甚至超过100行,因为它需要在sID上搜索以添加To.我想我可以将连接编写为SQL函数以避免FOR XML AUTO,但使用FOR XML的查询速度很快,并提供了我需要的确切结果.这是如何检索结果?
有
List<byte> lbyte
Run Code Online (Sandbox Code Playgroud)
有
byte[] searchBytes
Run Code Online (Sandbox Code Playgroud)
如何搜索lbyte不仅仅是一个字节,而是搜索searchBytes的索引?
例如
Int32 index = lbyte.FirstIndexOf(searchBytes);
Run Code Online (Sandbox Code Playgroud)
这是我提出的蛮力.
不是我要找的表现.
public static Int32 ListIndexOfArray(List<byte> lb, byte[] sbs)
{
if (sbs == null) return -1;
if (sbs.Length == 0) return -1;
if (sbs.Length > 8) return -1;
if (sbs.Length == 1) return lb.FirstOrDefault(x => x == sbs[0]);
Int32 sbsLen = sbs.Length;
Int32 sbsCurMatch = 0;
for (int i = 0; i < lb.Count; i++)
{
if (lb[i] == sbs[sbsCurMatch])
{
sbsCurMatch++;
if (sbsCurMatch == sbsLen)
{
//int …Run Code Online (Sandbox Code Playgroud) 我有一个简单的选择语句.它基本上是2个CTE,一个包括一个ROW_NUMBER()OVER(PARTITION BY,然后从这些连接到另外4个表.没有函数或任何异常.
WITH Safety_Check_CTE AS
(
SELECT
Fact_Unit_Safety_Checks_Wkey,
ROW_NUMBER() OVER (PARTITION BY [Dim_Unit_Wkey], [Dim_Safety_Check_Type_Wkey]
ORDER BY [Dim_Safety_Check_Date_Wkey] DESC) AS Check_No
FROM
[Pitches].[Fact_Unit_Safety_Checks]
), Last_Safety_Check_CTE AS
(
SELECT
Fact_Unit_Safety_Checks_Wkey
FROM
Safety_Check_CTE
WHERE
Check_No = 1
)
SELECT
COUNT(*)
FROM
Last_Safety_Check_CTE lc
JOIN
Pitches.Fact_Unit_Safety_Checks f ON lc.Fact_Unit_Safety_Checks_Wkey = f.Fact_Unit_Safety_Checks_Wkey
JOIN
DIM.Dim_Unit u ON f.Dim_Unit_Wkey = u.Dim_Unit_Wkey
JOIN
DIM.Dim_Safety_Check_Type t ON f.Dim_Safety_Check_Type_Wkey = t.Dim_Safety_Check_Type_Wkey
JOIN
DIM.Dim_Date d ON f.Dim_Safety_Check_Date_Wkey = d.Dim_Date_Wkey
WHERE
f.Safety_Check_Certificate_No IN ('GP/KB11007') --option (maxdop 1)
Run Code Online (Sandbox Code Playgroud)
有时它返回0,1或2行.结果显然应该是一致的.
我在复制问题时运行了配置文件跟踪,我的会话是数据库中唯一的一个.
我已经比较了实际执行计划,它们都是相同的,除了最终的哈希匹配返回不同的行数.
如果我使用MAXDOP 0,我无法复制.

.net ×4
t-sql ×4
sql-server ×3
c# ×2
wpf ×2
background ×1
binding ×1
dictionary ×1
linq ×1
list ×1
listbox ×1
selecteditem ×1
wildcard ×1
xaml ×1
xml ×1
xpsdocument ×1