小编Kis*_*mar的帖子

EntityFramework中的公用表表达式

我在Sql Server中有这个查询,我需要在EntityFramework中使用,那么如何编写一个与此结果相同的EntityFramwork代码

WITH    cte AS
        (
        SELECT  *
        FROM    StockGroups
        WHERE   GroupParent ='Stationery' 
        UNION ALL
        SELECT  g.*
        FROM    StockGroups g
        JOIN    cte
        ON      g.GroupParent = cte.GroupName
        )
SELECT  *
FROM    cte
Run Code Online (Sandbox Code Playgroud)

我不知道如何在EF中转换它,所以我尝试使用join.

from a in db.StockGroups
join b in db.StockGroups on new { GroupParent = a.GroupParent } equals new { GroupParent = b.GroupName }
where
  b.GroupName == "Stationery"
select new {
  a.GroupName,
  a.GroupParent,
  Column1 = b.GroupName,
  Column2 = b.GroupParent
}
Run Code Online (Sandbox Code Playgroud)

但结果并不像CTE一样递归.

.net c# linq common-table-expression entity-framework-4

7
推荐指数
3
解决办法
8383
查看次数

非静态类比静态类有什么优势?

非静态类比静态类有什么优势?

静态类不需要实例化。所以我们可以直接使用ClassName.MemberName,那么非静态类的用途是什么

.net c#

6
推荐指数
1
解决办法
6679
查看次数

哪个最适合用于从byte []创建文件?

我想用byte []创建一个文件,哪个最好.

byte[] content=File.ReadAllBytes(@"C:\ServiceLog.txt");

FileStream stream = new FileStream(@"C:\ServiceLog1.txt", FileMode.Create, FileAccess.ReadWrite);
stream.Write(content, 0, content.Length);
stream.Close();
Run Code Online (Sandbox Code Playgroud)

要么

 File.WriteAllBytes(@"C:\12.txt",content);
Run Code Online (Sandbox Code Playgroud)

.net c# file

6
推荐指数
2
解决办法
2万
查看次数

LINQ to Entities无法识别该方法,并且此方法无法转换为存储表达式

var ps = dbContext.SplLedgers.Select(p => new SplLedgerModel
            {
                Name = p.Name,
                VoucherType = Convert.ToString(((JIMS.VoucherTypes)p.VoucherType))
        });
Run Code Online (Sandbox Code Playgroud)

我得到以下异常,代码有什么问题.

JIMS.VoucherType是一个枚举

+       $exception  {"LINQ to Entities does not recognize the method 'System.String ToString(System.Object)' method, and this method cannot be translated into a store expression."}    System.Exception {System.NotSupportedException}
Run Code Online (Sandbox Code Playgroud)

.net c# wpf entity-framework linq-to-sql

6
推荐指数
1
解决办法
3467
查看次数

Windows 8.1是否支持Visual Studio 6.0(Visual Basic 6)的安装?

我有一个在Visual Basic 6中开发的旧项目,我需要在其中进行增强.

我需要确认是否可以在Windows 8.1上安装Visual Studio 6.

上次,当我在Windows 7中安装它时,我遇到了安装方面的困难,但最终在添加了一些DLL之后完成了.

我不想浪费时间,所以,如果有人已经设法安装它,你能和我们分享一下吗?

vb6 visual-studio-6 windows-8.1

6
推荐指数
1
解决办法
2万
查看次数

在WPF DataGrid中使用Enter键作为选项卡

我有一个DataGridWPF.

我想在我点击Enter时移动到NextCell ,当到达LastColumn时,它应该具有Enter创建或移动到下一行的默认功能.

我不想用 Tab

我怎么能在WPF中这样做.

c# wpf datagrid mvvm

5
推荐指数
1
解决办法
4200
查看次数

如何在 WPF 中找到 UserControl 宽度?

<UserControl x:Class="JIMS.View.Settings.Settings"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    Name="SettingsWindow">       
    <Border Style="{StaticResource WindowBorderStyle}" Height="100">    
    <StackPanel Orientation="Vertical">
        <my:TitleBar Title="settings"/>
        <StackPanel Orientation="Horizontal">
            <StackPanel Orientation="Horizontal">
                <StackPanel Orientation="Vertical" Margin="10,0,0,0">
                    <Label>Theme :</Label>                        
                </StackPanel>
                <StackPanel Orientation="Vertical" Width="200" Margin="0,0,10,0">                        
                    <ComboBox Name="cmbTheme" ItemsSource="{Binding Path=Themes}" ></ComboBox>                        
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </StackPanel>        
</Border>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

这是我的 UserControl,我还没有设置它的 Width 和 Height 属性。但是在某些代码隐藏中,我想获得此 UserControl 的高度和宽度,但我无法获得它们。

double width=uctrl.Width;
Run Code Online (Sandbox Code Playgroud)

它让我NaN同时

double width=ctrl.ActualWidth;
Run Code Online (Sandbox Code Playgroud)

给我 0

我需要宽度和高度的代码

private void OpenChild(UserControl ctrl)
{
    bool alreadyExist = false;
    ctrl.Uid = ctrl.Name;
    foreach (UIElement child in JIMSCanvas.Children)
    {
        if (child.Uid == ctrl.Uid)
        {
            alreadyExist …
Run Code Online (Sandbox Code Playgroud)

c# wpf user-controls

5
推荐指数
1
解决办法
4955
查看次数

使用EventAggregator更新Aurelia中的列表

我正在使用app-contacts演示来学习Aurelia,是的我知道,它是不完整的,如@Eisenberg所提到的,但后来当我保存联系人或创建新联系人时,我想使用EventAggregator通知app.js.直到现在一切正常.我能够在app.js中收到联系人对象,但现在我想更新联系人列表,这不起作用,当我保存联系人并更新app.js中的联系人列表时,它将被删除.

在app.js中添加的代码和在构造函数中调用subscribe方法.

subscribe(){
    this.ea.subscribe('contact_event', payload => {
        console.log(payload);
        var instance = JSON.parse(JSON.stringify(payload));
        let found = this.contacts.filter(x => x.id == payload.id)[0];

        if(found){
            let index = this.contacts.indexOf(found);
            this.contacts[index] = instance;
        }else{
            instance.id = this.contacts.length + 1;
            this.contacts.push(instance);
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

没有对app.html进行任何更改

<li repeat.for="contact of contacts" class="list-group-item ${contact.id === $parent.selectedId ? 'active' : ''}">
  <a href="#" click.delegate="$parent.select(contact)">
    <h4 class="list-group-item-heading">${contact.firstName} ${contact.lastName}</h4>
    <p class="list-group-item-text">${contact.email}</p>
  </a>
</li>
Run Code Online (Sandbox Code Playgroud)

如何更新列表?

更新 这对我有用,但不确定什么是正确的方法

subscribe(){    
  this.ea.subscribe('contact_event', payload => {
    return this.api.getContactList().then(contacts => {
      this.contacts = contacts;
    });
  });
}
Run Code Online (Sandbox Code Playgroud)

javascript aurelia aurelia-event-aggregator

5
推荐指数
1
解决办法
1171
查看次数

如何更改WPF ComboBox SelectedText BackGround Color?

我在WPF-MVVM中有一个Combobox,我在组合框的弹出框和文本框中更改了组合框.

当我滚动组合框列表项时,他的背景是粉红色的,这就是我所拥有的.但是从组合框列表中选择项目后,组合框项目中的选定值具有蓝色背景.这是Windows窗体和WPF中组合框的默认设置.

有关详细信息,请参见图像.

在此输入图像描述

如何在组合框文本框控件中更改选定的文本背景颜色

组合框有

IsEditable=True 财产集

.net c# wpf xaml mvvm

4
推荐指数
2
解决办法
3万
查看次数

如何使用CommandParameter传递UserControl?

我使用DelegateCommand,我想通过Command传递UserControl.

#region OpenViewCommand
private DelegateCommand<UserControl> _openViewCommand;
public ICommand OpenViewCommand
{
    get
    {
        if (_openViewCommand == null)
            _openViewCommand = new DelegateCommand<UserControl>(new Action<UserControl>(OpenView));
        return _openViewCommand;
    }
}

public void OpenView(UserControl ViewName)
{
    UserControl ctrl = (UserControl)ViewName;
    JIMS.Controls.Message.Show(ViewName.ToString());
}
#endregion
Run Code Online (Sandbox Code Playgroud)

XAML中的命令

<Button Name="btnStockGroups" Command="{Binding OpenViewCommand}" CommandParameter="JIMS.View.Stock.StockGroups">stock group</Button>
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml binding view

4
推荐指数
1
解决办法
6366
查看次数