小编Ala*_*yne的帖子

从样式设置器中取消选中复选框?

我有多个以下形式的数据触发器:

 <Style x:Key="VerifyCheckBox" TargetType="{x:Type CheckBox}">
            <Setter Property="Height" Value="14" />
            <Setter Property="FontSize" Value="12" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=PrimaryInsuranceCompany, Path=(Validation.HasError)}" Value="True">
                    <Setter Property="IsEnabled" Value="False" />
                    <Setter Property="IsChecked" Value="False" />
                </DataTrigger>
Run Code Online (Sandbox Code Playgroud)

CheckBoxIsEnabled上的属性设置 正确。但是,如果一开始就手动检查过该属性,则该属性不会被取消检查。IsChecked

可以IsChecked从 Setter 中取消选中吗?

编辑#1

To complicate matters a bit more, the checkbox is bound to a property in my viewmodel as:

  <CheckBox 
                  Style="{StaticResource VerifyCheckBox}"
                  IsChecked="{Binding PrimaryInsurance.SelectedInsurance.Verify}" 
                  Content="Verify" HorizontalAlignment="Left" Margin="789,92,0,676" Width="46" />
Run Code Online (Sandbox Code Playgroud)

Style.Triggers 中有多个 DataTrigger,每个 DataTrigger 检查 UI 上的不同元素。简而言之,UI 具有所有数据验证功能。例如,上面命名的元素 PrimaryInsuranceCompany 是:

 <wc:AutoFilteredComboBox 
                  Name="PrimaryInsuranceCompany"
                  IsEnabled="{Binding PrimaryInsurance.Enabled}" …
Run Code Online (Sandbox Code Playgroud)

wpf xaml datatrigger

3
推荐指数
1
解决办法
1678
查看次数

如何有效地检查 PostgreSQL 中已使用和未使用值的序列

在 PostgreSQL (9.3) 中,我有一个表定义为:

CREATE TABLE charts
( recid serial NOT NULL,
  groupid text NOT NULL,
  chart_number integer NOT NULL,
  "timestamp" timestamp without time zone NOT NULL DEFAULT now(),
  modified timestamp without time zone NOT NULL DEFAULT now(),
  donotsee boolean,
  CONSTRAINT pk_charts PRIMARY KEY (recid),
  CONSTRAINT chart_groupid UNIQUE (groupid),
  CONSTRAINT charts_ichart_key UNIQUE (chart_number)
);

CREATE TRIGGER update_modified
  BEFORE UPDATE ON charts
  FOR EACH ROW EXECUTE PROCEDURE update_modified();
Run Code Online (Sandbox Code Playgroud)

我想用如下序列替换chart_number:

CREATE SEQUENCE charts_chartnumber_seq START 16047;
Run Code Online (Sandbox Code Playgroud)

以便通过触发器或函数,添加新图表记录自动按升序生成新图表编号。但是,没有现有的海图记录可以更改海图编号,而且多年来分配的海图编号一直存在跳跃现象。因此,在为新图表记录分配新图表编号之前,我需要确保尚未使用“新”图表编号,并且没有为具有图表编号的任何图表记录分配不同的编号。

如何才能做到这一点?

postgresql sequence gaps-and-islands

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

如何正确调用类库中的P/Invoke方法?

我在Visual Studio 2015解决方案中有多个项目.其中一些项目执行P/Invokes,如:

 [DllImport("IpHlpApi.dll")]
        [return: MarshalAs(UnmanagedType.U4)]
        public static extern int GetIpNetTable(IntPtr pIpNetTable, [MarshalAs(UnmanagedType.U4)]
        ref int pdwSize, bool bOrder);
Run Code Online (Sandbox Code Playgroud)

所以我将所有的P/Invokes移动到一个单独的类库中,并将单个类定义为:

namespace NativeMethods
{
    [
    SuppressUnmanagedCodeSecurityAttribute(),
    ComVisible(false)
    ]

    public static class SafeNativeMethods
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern int GetTickCount();

        // Declare the GetIpNetTable function.
        [DllImport("IpHlpApi.dll")]
        [return: MarshalAs(UnmanagedType.U4)]
        public static extern int GetIpNetTable(IntPtr pIpNetTable, [MarshalAs(UnmanagedType.U4)]
        ref int pdwSize, bool bOrder);
    }
}
Run Code Online (Sandbox Code Playgroud)

从其他项目中,此代码称为:

 int result = SafeNativeMethods.GetIpNetTable(IntPtr.Zero, ref bytesNeeded, false);
Run Code Online (Sandbox Code Playgroud)

所有编译都没有错误或警告.

现在在代码上运行FxCop会发出警告:

警告CA1401更改P/Invoke'SafeNativeMethods.GetIpNetTable(IntPtr,ref int,bool)'的可访问性,以便从其程序集外部不再可见.

好.将可访问性更改为内部:

[DllImport("IpHlpApi.dll")]
[return: …
Run Code Online (Sandbox Code Playgroud)

c# pinvoke native-methods

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

在 F# 中,表达式的类型应该是“Nullable&lt;DateTime&gt;”,但这里的类型是“DateTime”

我在 F# 中有以下函数,它从本地数据库返回数据:

let GetScheduleAsync (tableDate : DateTime) =
        async {
            let! data = context.GetOfficeScheduleAsync(tableDate) |> Async.AwaitTask
            return data |> Seq.map(fun q -> {
                Visit.lastName = q.lastname
                firstName = q.firstname
                birthDate = q.birthdate 
                appointmentTime = q.appointment_time
                tservice = q.service_time
                postingTime = q.posting_time
                chartNumber = q.chart_number
                })                  
          }
          |> Async.StartAsTask
Run Code Online (Sandbox Code Playgroud)

其中访问定义为:

type Visit = {
    lastName : string
    firstName : string
    birthDate : Nullable<DateTime>
    appointmentTime : Nullable<DateTime>
    tservice : Nullable<DateTime>
    postingTime : Nullable<DateTime>
    chartNumber : Nullable<int>
    }
Run Code Online (Sandbox Code Playgroud)

现在从数据库下载的 q.birthdate 是非空的,但访问定义将其设置为可以为空。因此,导致以下错误:

The …
Run Code Online (Sandbox Code Playgroud)

f#

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

如何从 Dapper(使用 Npgsql)调用具有混合大小写名称的存储过程?

来自 NuGet,我正在使用

...\packages\Npgsql.2.2.5\lib\net45\Npgsql.dll

...\packages\Dapper.1.42\lib\net45\Dapper.dll

在 PostgreSQL 中调用存储过程时,我需要将过程名称的大小写保留为

var x = cnn.Query<icd9>("GetDxLibrary", commandType: CommandType.StoredProcedure);
Run Code Online (Sandbox Code Playgroud)

我收到运行时错误:

Npgsql.dll 中发生“Npgsql.NpgsqlException”类型的未处理异常

附加信息:错误:42883:函数 getdxlibrary() 不存在。

如果 PostgreSQL 中的函数重命名为getdxlibrary(),一切顺利。

如何在 Dapper 中调用大小写混合名称的过程?

TIA

postgresql stored-procedures npgsql dapper

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

如何在PostgreSQL中迁移数据库之前将所有序列重置为1?

(PostgreSQL 9.4)

我正在将旧数据库迁移到新架构。在使用pg_restore从开发机器获取新模式(没有数据)之后,我发现某些序列不是从1开始的。(在开发过程中,我更改了多个序列以使用更高的值)。

在开始数据库迁移之前,是否可以通过编程方式将所有序列(其中一些不是主键)重置为1?

感谢您的帮助或建议。

database postgresql-9.4

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

在PostgreSQL中使用带有变量的正则表达式的正确语法

PostgreSQL 9.5.4

我有以下功能,我试图使用正则表达式中的参数.就像是

CREATE OR REPLACE FUNCTION test(lastname text, firstname text, birthdate date)
  RETURNS SETOF view_patient AS
$BODY$ 

   select * from testing t
   where t.lastname ~*  '^' || $1 || ''
   order by t.lastname

$BODY$
  LANGUAGE sql VOLATILE;
Run Code Online (Sandbox Code Playgroud)

返回的错误是:

错误:WHERE的参数必须是boolean类型,而不是类型文本LINE 55:其中t.lastname~*'^'|| 1美元|| ""

这是怎么做到的?

TIA

regex postgresql

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

在 F# 中,如何修复值类型“a-&gt;'b-&gt;Model”的模式匹配错误

(我是 F# 新手)。我在 F# 中有以下定义:

init i j =
    { Id = Guid.NewGuid ()
      InnerRows = [0 .. 2] |> List.map (Cell.init i j) 
      SelectedInnerRow = None}

 let update msg m =
    match msg with
    | Select id -> { m with SelectedInnerRow = id }
    | Reset -> init
Run Code Online (Sandbox Code Playgroud)

其中更新函数在“重置 -> 初始化”上显示以下错误: 模式匹配表达式的所有分支必须返回与第一个分支相同类型的值,其中此处为“模型”。该分支返回类型为 ''a -> 'b -> Model' 的值

“a -> 'b -> Model”是什么意思,如何解决这个问题?

谢谢。

TIA

f# pattern-matching

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

在 F# 中,如何对 Nullable&lt;DateTime&gt; 与 Null 进行模式匹配?

(真糊涂)。

请假设我从 WCF 服务下载了一个访问:

type Visit = {
               tservice : Nullable<DateTime>
             }
Run Code Online (Sandbox Code Playgroud)

和一个由访问组成的访问数组。假设数组中的某些访问具有非空 tservice 而其他访问具有空 tservice 值,tservice 模式如何与 null 匹配?

即这失败了:,

let fillSchedule (v:Visits[]) =
       v |> Array.iter ( fun f -> 
                            match f.tservice with
                            | System.Nullable<DateTime>  -> tservice IS null, do something
                            | _ -> tservice is NOT null,  do something
            
                       )
Run Code Online (Sandbox Code Playgroud)

提前致谢。

f# nullable

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

在 F# 中,如何对 Nullable 属性进行排序?

我有一个从数据库下载的数组,其中的属性 service_time 是Nullable<DateTime>

service_time: Nullable<DateTime>
Run Code Online (Sandbox Code Playgroud)

在 F# 中,如何对这个数组进行排序,将 service_time = null 的所有元素放在新数组的最前面?

Array.sortBy (fun t -> t.service_time)
Run Code Online (Sandbox Code Playgroud)

给出:“Nullable”类型不支持“比较”约束。

f#

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

正则表达式的日期模式?

尝试在C#中编写一个接受以下任何/所有内容的正则表达式:

  1. 1968年2月1日
  2. 1968年2月1日
  3. 1968年2月1日

(这个问题与其他类似的问题有些不同,因为这是一个单词,采用mm/dd/yyyy格式.只需要模式而不需要验证它的可能性.即99/99/9999是好的)

我无处可去.据我所知(这只承认02/01/1968):

Regex regex = new Regex(@"^\d{2}/\d{2}/\d{4}$",RegexOptions.IgnorePatternWhitespace);
Match x = regex.Match(birthdate);
if (x.Success == false) return;
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.(对正则表达式的解释将是最受欢迎的).

c# regex

0
推荐指数
1
解决办法
4825
查看次数

如何实现List <T,T>?

我有一个对象列表:

  MyDisplayObjects = new List<ISave> { Patient, ServiceBilling, ReferredBy, POA, PrimaryInsurance, SecondaryInsurance };
Run Code Online (Sandbox Code Playgroud)

每个对象从ISave继承的地方

foreach (var o in MyDisplayObjects)
 {
  o.CanSaveEvent += new EventHandler<CanSaveEventArgs>(CanSaveEventHandler);
 }
Run Code Online (Sandbox Code Playgroud)

完美的工作.

现在我想为每个对象ISelfPay添加一个单独的接口,并执行:

  MyDisplayObjects = new List<ISave,ISelfPay> { Patient, ServiceBilling, ReferredBy, POA, PrimaryInsurance, SecondaryInsurance };
Run Code Online (Sandbox Code Playgroud)

所以这也会起作用:

foreach (var o in MyDisplayObjects)
{
  o.CanSaveEvent += new EventHandler<CanSaveEventArgs>(CanSaveEventHandler);
  this.SelfPayEvent += new EventHandler<SelfPayEventArgs>(o.CheckInViewModel_SelfPayEvent);
 }
Run Code Online (Sandbox Code Playgroud)

错误:无法使用集合初始值设定项初始化List <'ISave,ISelfPay'>类型的对象.

我似乎无法为Google找到太多帮助.这是怎么做到的?

(我可以制作两个列表,但是如果可能的话,我想学习如何使用一个列表.:)

TIA

c# list

0
推荐指数
1
解决办法
120
查看次数