小编Mic*_*uen的帖子

Sql条件不空约束


我很想知道是否有可能在sql中创建一个条件非空约束?换句话说,可以创建一个约束,使得列B可以为空,因为列A包含让我们说"新",但如果列A的内容更改为其他内容,则不再允许列B为空?
为了扩展,只要列A表示"新",就可以使列B必须为空或为空?
谢谢大家:D

sql constraints notnull

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

这个thread.abort()是否正常且安全?

我创建了一个自定义自动完成控件,当用户按下一个键时,它会在另一个线程上查询数据库服务器(使用Remoting).当用户输入非常快时,程序必须取消先前执行的请求/线程.

我以前首先将它实现为AsyncCallback,但我发现它很麻烦,要遵循的房子规则太多(例如AsyncResult,AsyncState,EndInvoke)加上你必须检测BeginInvoke'd对象的线程,这样你就可以终止先前执行的线程了.此外,如果我继续AsyncCallback,那些AsyncCallbacks上没有可以正确终止先前执行线程的方法.

EndInvoke无法终止线程,它仍然会完成待终止线程的操作.我仍然会在线程上使用Abort().

所以我决定用纯线程方法实现它,没有AsyncCallback.这个thread.abort()是否正常且安全吗?

public delegate DataSet LookupValuesDelegate(LookupTextEventArgs e);

internal delegate void PassDataSet(DataSet ds);

public class AutoCompleteBox : UserControl
{
   Thread _yarn = null;

   [System.ComponentModel.Category("Data")]
   public LookupValuesDelegate LookupValuesDelegate { set; get; }

   void DataSetCallback(DataSet ds)
   {
      if (this.InvokeRequired)
         this.Invoke(new PassDataSet(DataSetCallback), ds);
      else
      {
         // implements the appending of text on textbox here
      }
   }

   private void txt_TextChanged(object sender, EventArgs e)
   {
      if (_yarn != null) _yarn.Abort();

      _yarn = new Thread(
         new Mate
         {
            LookupValuesDelegate = this.LookupValuesDelegate,
            LookupTextEventArgs =
            new LookupTextEventArgs …
Run Code Online (Sandbox Code Playgroud)

c# multithreading

20
推荐指数
2
解决办法
9746
查看次数

如何将List <Integer>的值而不是引用复制到另一个列表中?

也就是说,在不引用同一对象的情况下,我需要将一个列表的元素值复制到另一个列表中.这些是列表:

List<Integer> listA = new ArrayList<Integer>();
List<Integer> ListB = new ArrayList<Integer>();

listA = (added some values);

listB = (do what?)...
Run Code Online (Sandbox Code Playgroud)

PS.我为初学者的问题道歉,但我从未做过这样的事情.

java arraylist

17
推荐指数
3
解决办法
5万
查看次数

为什么我在编码网站上看到的大多数DataContract的DataMembers都不是使用自动属性编写的?

以此网站为例:http://www.c-sharpcorner.com/UploadFile/ankithakur/ExceptionHandlingWCF12282007072617AM/ExceptionHandlingWCF.aspx

[DataContract]
public class MyFaultException
{
    private string _reason;

    [DataMember]
    public string Reason
    {
        get { return _reason; }
        set { _reason = value; }
    }
}
Run Code Online (Sandbox Code Playgroud)

考虑到WCF在.NET 3.0中启动并且C#3已经具有自动属性,是否有任何理由支持这种方法?为什么不写如下?

[DataContract]
public class MyFaultException
{
    [DataMember]
    public string Reason { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

c# wcf design-patterns

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

为什么最自然的查询(即使用INNER JOIN(而不是LEFT JOIN))非常慢

此查询需要太长时间.

explain analyze

select 

c.company_rec_id, 
c.the_company_code ,
c.company

from 
tlist t

-- it is questionable why this query become fast when using left join, the most natural query is inner join...
join mlist m using(mlist_rec_id)
join parcel_application ord_app using(parcel_application_rec_id)
join parcel ord using(parcel_rec_id)
join company c on c.company_rec_id = ord.client_rec_id
-- ...questionable

where 
(
    'cadmium' = ''

    or

    exists
    (
    select * 
        from mlist_detail md
        where 
            md.mlist_rec_id = m.mlist_rec_id        
            and exists
            (
                select *
                from mlist_detail_parameter mdp            
                join parameter p …
Run Code Online (Sandbox Code Playgroud)

sql postgresql optimization

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

ServiceStack Razor继承指令没有智能感知

我正在学习ServiceStack剃须刀并且想要用它来改进(一般来说是ServiceStack),虽然我无法通过继承指令获得intellisense(通过继承指令)

在此输入图像描述

这是我到目前为止的尝试:http://www.ienablemuch.com/2012/12/self-hosting-servicestack-serving.html

razor servicestack

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

NHibernate FetchMany在两个以上的表上被破坏了吗?

鉴于这种:

namespace TheEntities
{
    [DataContract(IsReference=true)]    
    public class Question
    {
        [DataMember] public virtual int QuestionId { get; set; }
        [DataMember] public virtual string Text { get; set; }
        [DataMember] public virtual string Poster { get; set; }

        [DataMember] public virtual IList<QuestionComment> Comments { get; set; }
        [DataMember] public virtual IList<Answer> Answers{ get; set; }



        [DataMember] public virtual byte[] RowVersion { get; set; }
    }

    [DataContract]
    public class QuestionComment
    {
        [DataMember] public virtual Question Question { get; set; }        

        [DataMember] public virtual …
Run Code Online (Sandbox Code Playgroud)

nhibernate entity-framework

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

将超大规模查询从SQL Server转换为MySQL - JOIN问题

我有一个在SQL Server 2008中运行良好的查询但是当我尝试将它与MySQL一起使用时,它似乎是问题JOIN.

第一个错误是

您的SQL语法有错误; 检查在52" 行对应于你的MySQL服务器版本使用附近的正确语法"ON faxcont.IDDireccion = dir_cont.RecID和faxcont.Tipo = 2,faxcont.Defecto"手册

如何纠正?

SELECT     req.RecID, req.FechaEntrega, req.IDUsuario AS RecIDResp, req.NroSucursal, req_dp.NroFila, req.ID, req.ID AS NroReq, emp.Empresa AS NombreEmpresa, 
req.IDFiscalSistema, req_dp.ImporteUnitario1, req_dp.ImporteUnitario2, req_dp.ImporteUnitario3, req_dp.ImporteUnitario4, req_dp.ImporteUnitario5, 
req_dp.ImporteUnitario6, req.NroMoneda, req_dp.SobrePrecio, req_dp.Impuesto AS TasaIVA, dir_emp_sist.CodPais AS CodPaisEmpresa, 
dir_emp_sist.CodCiudad AS CodCiudadEmpresa, tel.numero AS TelefonoEmpresa, fax.numero AS FaxEmpresa, mail_emp.Direccion AS MailEmpresa, 
emp_sist.SitioWeb AS WebEmpresa, dir_cont.CodPais AS CodPaisCont, dir_cont.CodCiudad AS CodCiudadCont, telcont.numero AS TelefonoCont, 
faxcont.numero AS FaxCont, req.FechaModificacion AS FechaGrabacion, cont.Apellido AS ApellidoCont, cont.Nombre AS …
Run Code Online (Sandbox Code Playgroud)

mysql sql sql-server join sql-server-2008-r2

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

在你的第一个程序中,哪个构造吸引你编程?

对我来说,这是If声明,我很兴奋,从那以后我相信计算机非常聪明,或者我至少可以让它看起来很聪明.

language-agnostic language-construct

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

代码生成器与代码重构

你觉得你的CRUD程序怎么样?代码生成,框架驱动或手动编写?

refactoring

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