WPF xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

本文介绍了一种SQL查询方法,用于获取数据库中所有表的名称及其对应的行数。通过使用内连接的方式,结合sysobjects和sysindexes视图来实现这一目标。

<Button Grid.Row="1" Content="Load Data" BorderBrush="Black" BorderThickness="10">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding loadCmd}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>

查询数据库中所有表表名,行数
SELECT a.name, b.rows 
FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1))
ORDER BY b.rows DESC

转载于:https://www.cnblogs.com/Fred1987/p/6239014.html

C# using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApp1 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public class StatusToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is bool isEnabled) { return isEnabled ? Brushes.Red : Brushes.Green; } return Brushes.Gray; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } public class MainViewModel : INotifyPropertyChanged { private bool _isAutoTradingEnabled; public bool IsAutoTradingEnabled { get => _isAutoTradingEnabled; set { _isAutoTradingEnabled = value; OnPropertyChanged(); OnPropertyChanged(nameof(ToggleButtonText)); } } public string ToggleButtonText => IsAutoTradingEnabled ? "关闭自动下单" : "开启自动下单"; public ICommand ToggleCommand => new RelayCommand(ToggleStatus); private void ToggleStatus(object obj) { IsAutoTradingEnabled = !IsAutoTradingEnabled; } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } public class RelayCommand : ICommand { private readonly Action<object> _execute; public RelayCommand(Action<object> execute) => _execute = execute; public bool CanExecute(object parameter) => true; public void Execute(object parameter) => _execute(parameter); public event EventHandler CanExecuteChanged; } } <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Title="自动下单控制" Height="200" Width="300">> <Window.Resources> <local:StatusToColorConverter x:Key="ColorConverter"/> </Window.Resources> <Window.DataContext> <local:MainViewModel/> </Window.DataContext> <Grid> <Button Content="{Binding ToggleButtonText}" Background="{Binding IsAutoTradingEnabled, Converter={StaticResource ColorConverter}}" Command="{Binding ToggleCommand}" Width="150" Height="40" FontSize="14" FontWeight="Bold" Margin="10"/> </Grid> </Window>
08-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值