问题列表 - 第20391页

如何在不更改记录数据的情况下更新sql server timestamp列

我有一个带有时间戳列的SQL Server表.有没有办法强制时间戳列更改而不实际更新记录?

我问的原因是因为我想在子表中插入/更新/删除记录时更改记录的时间戳.

时间戳可能不是执行此操作的最佳方式.如果没有,我该怎么办?我不想使用datetime,因为我觉得这不是一个很好的版本控制方式.我不想使用整数,因为我不想读取值来增加它.

建议?

.net c# sql sql-server

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

R:从命名空间调用函数

我正在尝试改变R中包中的一些命令的功能.很容易看到命令的来源.但是,该函数调用包命名空间中的其他函数.这些函数不是导出的对象.那我该如何访问它们呢?

具体示例:如何访问copula :: rmvdc中使用的asCall()函数?

require(copula)
copula::rmvdc
getAnywhere("asCall")
Run Code Online (Sandbox Code Playgroud)

所以as.Call()在copula包中存在,但我该如何访问它?

> copula::asCall
Error: 'asCall' is not an exported object from 'namespace:copula'
Run Code Online (Sandbox Code Playgroud)

namespaces r

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

恐慌与断言之间有什么区别?

Go不提供断言.它们无疑是方便的,但我们的经验是程序员将它们用作拐杖以避免考虑正确的错误处理和报告.

然而,它具有打印和println哪些呢

像打印一样恐慌,打印
panicln之后执行中止println,打印后中止执行

断言与断言相同吗?为什么他们会声称上述但却恐慌?我可以看到它导致相同的问题,但添加一个错误消息到它的结尾,很容易被滥用.我错过了什么吗?

go

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

LINQ,我应该加入还是使用嵌套的SELECT NEW

我必须低于2个LINQ语句.它们都返回(看似)相同的结果集.任何人都可以向我解释为什么我应该使用一种方式与另一种方式?它就像"你说土豆,我说土豆;你说番茄,我说番茄"一样简单吗?

以下是LINQ的两种风格 - >

1)以下两个lets是私有方法,它们获取一个ID并返回NAME.

var business = from businesse in context.tblBusinesses
               where businesse.BusinessID == businessID
               join addresse in context.tblAddresses on businesse.BusinessID equals addresse.BusinessID
               let stateName = GetStateNameByID(addresse.StateID)
               let countyName = GetCountyNameByID(addresse.CountyID)
               select new
               {
                   businesse.BusinessName,
                   businesse.ContactName,
                   businesse.EmailAddress,
                   addresse.AddressLine1,
                   addresse.AddressLine2,
                   addresse.AddressLine3,
                   addresse.CityName,
                   State = stateName,
                   addresse.ZipCode,
                   addresse.ZipPlus,
                   County = countyName
               };
Run Code Online (Sandbox Code Playgroud)

2)

var query = from businesse in context.tblBusinesses
            where businesse.BusinessID == businessID
            select new
            {
                businesse.BusinessName,
                businesse.ContactName,
                businesse.EmailAddress,
                Address = from addresse in businesse.tblAddresses 
                          select …
Run Code Online (Sandbox Code Playgroud)

.net c# linq linq-to-sql

9
推荐指数
2
解决办法
2057
查看次数

使用edmx文件时如何在连接字符串中指定元数据位置

我有一个web项目,其中包含在edmx文件中定义的数据模型.连接字符串的开头如下:

元数据= RES://*/;

这已经好了一段时间了.但是其他人在项目上创建了一个dll,它也使用了实体框架并将其添加到bin文件夹中.现在,当我尝试创建连接时,加载元数据时出错.

除了彻底改变我们中的一方或双方的工作方式外,我想知道如果我的连接字符串可以更改为只查找我的edmx文件中定义的元数据,问题是否可以解决.问题是,对于我的生活,我找不到正确的语法来做到这一点.元数据嵌入在输出程序集中,因此没有指向的物理元数据文件.我究竟应该如何在连接字符串中指定元数据位置?

asp.net entity-framework

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

Rails - HABTM关系...存储用户的复选框值

我试图弄清楚这个HABTM关系问题是为了我的数据库中的用户的利益存储.兴趣表包含具有id和名称的不同兴趣列表(即:id = 1,name ='Music')

我有一个用户模型=> user.rb

has_and_belongs_to_many :interests
Run Code Online (Sandbox Code Playgroud)

和兴趣模型=> interest.rb

has_and_belongs_to_many :users
Run Code Online (Sandbox Code Playgroud)

现在我正在尝试从复选框列表中编辑或更新用户的兴趣选择.控制器看起来像=>

def edit
#@interests = Interest.find(:all)

  @title = "Edit Interest"
  @user = User.find(session[:user_id])
  @user.interest ||= Interest.new
  interest = @user.interest
  if param_posted?(:interest)
      if @user.interest.update_attributes(params[:interest])
          flash[:notice] = "Changes saved."
          redirect_to :controller => "users", :action => "index"
      end
  end
end
Run Code Online (Sandbox Code Playgroud)

而param_posted函数看起来像这样

  def param_posted?(sym)
  request.post? and params[sym]
  end
Run Code Online (Sandbox Code Playgroud)

视图逻辑如下所示:

<% for interest in @interest %>
<div>
<%= check_box_tag "user[interest_id][]", interest.id, @user.interests.include (interest) %>
<%= interest.name %>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)

我认为一切看起来都很犹豫但是当我运行视图时我得到了错误:

InterestController#edit中的NoMethodError …

checkbox ruby-on-rails relational-database has-and-belongs-to-many

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

PHP - 在多维数组中合并重复的数组键

我有一个名为$ songs的多维数组,它输出以下内容:

Array
(
    [0] => Array
        (
            [Michael Jackson] => Thriller
        )

    [1] => Array
        (
            [Michael Jackson] => Rock With You
        )

    [2] => Array
        (
            [Teddy Pendergrass] => Love TKO
        )

    [3] => Array
        (
            [ACDC] => Back in Black
        )
)
Run Code Online (Sandbox Code Playgroud)

我想合并具有重复键的数组,所以我可以得到以下内容:

Array
(
    [0] => Array
        (
            [Michael Jackson] => Array
            (
                [0] => Thriller
                [1] => Rock With You
            )
        )

    [1] => Array
        (
            [Teddy Pendergrass] => Love TKO
        )

    [2] => Array …
Run Code Online (Sandbox Code Playgroud)

php arrays multidimensional-array

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

无法从App.Config中检索密钥

在我的WAP项目中,我引用了另一个C#项目(非Web).在那个C#项目中,我有一个app.config,我将其重命名为[projectName] .config

然后我尝试从我的[项目] .config中获取一个来自我的C#项目中的一些代码的密钥,它找不到它:

return ConfigurationManager.AppSettings["somekey"]
Run Code Online (Sandbox Code Playgroud)

所以我想知道为什么它无法读取我的app.config.我认为ConfigurationManager能够从Web项目的web.config和我的[projectName] .config(app.config)文件中读取密钥,该文件也在我引用的项目中?

asp.net

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

是否有一个常量描述.Net中的最小Windows FileTime值?

我使用DateTime.ToFileTime和FromFileTime方法来存储和检索数据库中的时间戳.最小的Windows文件时间是1601年1月1日午夜.是否存在类似于DateTime.MinValue的常量,它描述了这个值?

.net datetime constants

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

一个简单的WPF应用程序中的非托管泄漏

当鼠标移动到我的WPF应用程序上时,我遇到了泄漏非托管内存的情况.具体来说,当我在应用程序perfmon或Red Gate的内存分析器中分析应用程序时,私有字节单调增加,但所有托管堆中的字节保持不变 - 我相信,这意味着应用程序具有非托管泄漏.

我创建了一个简单的repro应用程序,但我看不出问题出在哪里.

该应用程序包含一个包含四个项目的ListView.在这些项目上快速移动鼠标会导致问题.

如果你有兴趣重现这个问题,这就是代码 - 它不是很漂亮,但它很简单.

谢谢


编辑:我已为此问题创建了Microsoft Connect问题.


App.xaml中

<Application x:Class="WpfLeakRepro.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Window1.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Generic.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)

App.xaml.cs

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace WpfLeakRepro
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

Generic.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <LinearGradientBrush x:Key="ListItemHover"
                         EndPoint="0,1"
                         StartPoint="0,0">
        <GradientStop Color="Aqua"
                      Offset="0" />
        <GradientStop …
Run Code Online (Sandbox Code Playgroud)

c# wpf memory-leaks

7
推荐指数
2
解决办法
2293
查看次数