我有一个大表,想知道是否可以提高查询性能.
allDocumentsWithPersianMonth有25000000记录
var normalDocuments = allDocumentsWithPersianMonth.Where(x => x.DocumentTypeId != 8 && x.DocumentTypeId != 9);
var debitOpening = allDocumentsWithPersianMonth.Where(x => x.DocumentTypeId == 8);
var creditOpening = allDocumentsWithPersianMonth.Where(x => x.DocumentTypeId == 8);
var debitClosing = allDocumentsWithPersianMonth.Where(x => x.DocumentTypeId == 9);
var creditClosing = allDocumentsWithPersianMonth.Where(x => x.DocumentTypeId == 9);
return allDocumentsWithPersianMonth
.GroupBy(x => new { x.DetailId, x.DetailCode, x.DetailDescription, x.PersianMonth })
.Select(g => new AccountsAgingViewModel
{
DetailId = g.Key.DetailId,
DetailCode = g.Key.DetailCode,
DetailDescription = g.Key.DetailDescription,
FarvardinDebit = normalDocuments.Where(x => x.DetailId == …Run Code Online (Sandbox Code Playgroud) 考虑像这样的表
debit credit code
-----------------------------
0 10 5
5 0 3
0 11 2
0 15 1
7 0 6
6 0 2
5 0 1
Run Code Online (Sandbox Code Playgroud)
我需要生成一个这样的结果集,首先是借记,然后按代码列排序:
debit credit code
----------------------------
5 0 1
6 0 2
5 0 3
7 0 6
0 15 1
0 11 2
0 10 5
Run Code Online (Sandbox Code Playgroud) 我想删除具有以下条件的所有外键.
SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_NAME IN ('Table1', 'Table2')
AND CONSTRAINT_NAME LIKE '%FK__%__DL%'
Run Code Online (Sandbox Code Playgroud) 我能够在 SSMS 中执行该函数,它返回预期值
SELECT *
FROM dbo.AccDocumentHeaders
WHERE TypeDocumentId = 1
AND dbo.MiladiToShamsi(DocumentDate, 'Saal') = 1395
Run Code Online (Sandbox Code Playgroud)
但在实体框架上,我在尝试执行以下命令时收到此错误:
var q= "SELECT *
FROM dbo.AccDocumentHeaders
WHERE TypeDocumentId=1
AND [dbo].MiladiToShamsi(DocumentDate,'Saal')=1395 ";
var result = _uow.AccDocumentHeaders.SqlQuery(q).ToList();
Run Code Online (Sandbox Code Playgroud)
找不到列“dbo”或用户定义函数找不到列“dbo”或用户定义函数或聚合“dbo.MiladiToShamsi”,或者名称不明确
任何帮助将不胜感激。
我需要提供一个WPF GridView,其中一列是a Combobox,用户可以从列表中选择一个值或输入一个新值,所以我设置IsComboBoxEditable为true但问题是如果用户键入的值不在ItemsSourceText中Combobox失去焦点时空白.
注意:我不希望在键入新值时,将此值添加到
ItemsSource.我只需要将它的string值保存在与它有界的行中.
我还需要DropDownOpened事件来填充它的ItemsSource.
这是我的代码:
<telerik:GridViewDataColumn Header="Description">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<telerik:RadComboBox IsEditable="True" ItemsSource="{Binding Descriptions}" Text="{Binding Description1,Mode=TwoWay}" DropDownOpened="descriptionRadComboBox_DropDownOpened"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
Run Code Online (Sandbox Code Playgroud)
Description1是string属性,Descriptions是string运行时填充的列表.(当DropDownOpened事件发生时)
我有enum这样的:
public enum DLTypeEnum
{
Others = 1, People = 2, Company = 4,
}
Run Code Online (Sandbox Code Playgroud)
我有这样一个属性ViewModel:
private DLTypeEnum _DLType;
public DLTypeEnum DLType
{
get { return _DLType; }
set { SetProperty(ref _DLType, value); }
}
Run Code Online (Sandbox Code Playgroud)
这是我的xaml:
<WrapPanel Grid.Row="3" Grid.Column="1">
<WrapPanel.Resources>
<Converter:EnumToBoolConverter x:Key="EnumToBooleanConverter" />
</WrapPanel.Resources>
<RadioButton GroupName="DLType" IsChecked="{Binding Path=DLType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static dlAccount:DLTypeEnum.Others}}"/>
<RadioButton GroupName="DLType" IsChecked="{Binding Path=DLType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static dlAccount:DLTypeEnum.People}}"/>
<RadioButton GroupName="DLType" IsChecked="{Binding Path=DLType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static dlAccount:DLTypeEnum.Company}}"/>
</WrapPanel>
Run Code Online (Sandbox Code Playgroud)
而这个转换器:
public class EnumToBoolConverter:IValueConverter
{ …Run Code Online (Sandbox Code Playgroud) 我有WindowTable以及以下数据:
SELECT Id FROM WindowTable WHERE OwnerRef=12
Id
----
25000
25001
25003
25004
25005
25006
25007
25008
Run Code Online (Sandbox Code Playgroud)
我想在ActionTable中为每个WindowTable行插入3行像这样:
Id WindowsRef ActionName ActionName2
-----------------------------------------------
1 25000 'Add' 'E'
2 25000 'DELETE' 'H'
3 25000 'UPDATE' 'B'
4 25001 'ADD' 'E'
5 25001 'DELETE' 'H'
6 25001 'Update' 'B'
. . .
. . .
Run Code Online (Sandbox Code Playgroud)
ActionTable.Id不是标识列
我在C#中有此代码
double result = 480 - 460.8;
Run Code Online (Sandbox Code Playgroud)
为什么结果是19.199999999999989而不是19.2?
sql-server ×4
t-sql ×4
c# ×2
sql ×2
xaml ×2
double ×1
enums ×1
gridview ×1
linq ×1
performance ×1
radio-button ×1
sql-insert ×1
types ×1
wpf ×1
wpfdatagrid ×1