首先,我认为 LINQ 很慢。 LINQ 几乎是一种嵌套数组迭代逻辑的干净方法。仅在 CPU 必须处理静态数据时使用。或者数据是 CPU 生成的并且没有后备存储。
反正我就是这么想的。现在来回答:
我在 SQLServer 2012 Express 中构建了一个数据库,用于 Demon-Striation 目的(
用户表::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::
浏览器表::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::
使用表示例(总共 324 行):::::::::::::::::::::::::::::::::::::: :::::::::::::::
图表:::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::
PIVOT(我将其添加为存储过程):::::::::::::::::::::::::::::::::::: ::::::::
VS 2012 / WPF 实现::::::::::::::::::
在添加存储过程后,将 VS 连接到您的数据库,并将数据集添加到您的项目中。将存储过程拖放到您的数据集中。您也可以在没有类型化数据集生成器的情况下使用存储过程。 See Here
WPF XAML::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::
<Window x:Class="WPFPIVOT.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid Name="datagrid" ItemsSource="{Binding}"/>
</Grid>
</Window>
.cs::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace WPFPIVOT
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Pivot pivoted;
PivotTableAdapters.GetUsageTableAdapter adapter;
public MainWindow()
{
InitializeComponent();
//this code is the same for WPF and FORMs
pivoted = new Pivot();
adapter = new PivotTableAdapters.GetUsageTableAdapter();
adapter.Fill(pivoted.GetUsage);
///////////////////////////////////////////////////////////////
datagrid.DataContext = pivoted;
}
}
}
WPF 窗口:::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::
(UserID 列默认为最右边的列,select 语句可能是select p1.UserID,p1[1],... p.[n])