Thursday, February 26, 2015

debugging a windows service

follow this pattern in program file

#if DEBUG
            MethodInfo mi = qCenterService.GetType().GetMethod("OnStart", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);
            mi.Invoke(BlahService, new object[] { new string[0] });
            Console.ReadLine();
#else
                     ServiceBase.Run(new ServiceBase[] { BlahService });

#endif

Monday, February 16, 2015

recent things done to an important and complex sql query to improve performance


  1. changed cross- apply to cte's
  2. added indices that had all the output columns needed instead of using clustered index which forced more reads
  3. removed max varchar columns from initial query to avoid key lookups and retrieved them at end of sql

Sunday, February 1, 2015

asp.net: Invalid postback or callback argument

<%@ Page EnableEventValidation="false" %>

CORS in asp.net

<httpProtocol>
        <customHeaders>
            <add name="Access-Control-Allow-Origin" value="*" />
            <add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS" />
            <add name="Access-Control-Allow-Headers" value="Content-Type, soapaction" />
        </customHeaders>
    </httpProtocol>

Friday, January 30, 2015

another simple sql question

drop table x
create table x(x int, y int)
insert into x values (1,2)
update  x set x=y , y=x
select * from x

what happens

Thursday, January 22, 2015

Would you believe...

select 1 where  'Draft' like  '%' + 'Dr' + '%'
select 1 where    '%' + 'Dr' + '%' like  'Draft'


i guess its obvious that what follows like is a subset

Thursday, January 15, 2015

Getting values out of a JSON object in c# when the object is an array


                         var values =    JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(strVal);
                         foreach (var val in values)
                           {
                               blah.Add(int.Parse(val.First(x => x.Key.Equals("blahId")).Value.ToString()));