Popular Posts
ADD ... THEN ... UNTIL ... data: begin of SERIES, N1 type I value 10, N2 type I value 20, N3 type I value 30, N4 type I value 40, ... Join related table and count rows or sum sql server 2005 count rows: SELECT * FROM Table1 LEFT JOIN     (SELECT Level1ID, COUNT(Level2ID) AS Total FROM Table2 GROUP BY Level1ID) AS... Append soap header into axis When axis generate classese of web service, it won't include the request of soap header. Here is a way to append soap header manually i...
Stats
Social Data Service

http://YOUR_SERVER_URL/PATH_TO_SITE_CONTAINING_LIST/_vti_bin/socialdataservice.asmx

C# 4.0's New Features
Named and Optional Parameters
public class Person
{
    public Person(string name, string gender = "Unknow", int age = 18) { }
}

var p1 = new Person("Bruce");  // only primary parameter
var p2 = new Person("Bruce", "Male");  // one optional parameter
var p3 = new Person("Bruce", "Male", 20);  // all parameters
var p4 = new Person("Bruce", age: 20);  // specified optional parameters

Dynamic Support
dynamic foo = 123;
foo = "foo";

dynamic p = new System.Dynamic.ExpandoObject();
p.age = 20;
p.name = "bruce";
Capitalize First Letters Of Words
string str = "EXTERNAL";
str = new string(str.Select((c, index) => index == 0 ? char.ToUpper(c) : char.ToLower(c)).ToArray());
Console.WriteLine(str);
// output: External
Get user info by account
SPUser user = SPContext.Current.Web.EnsureUser("domain\account");
Export list schema from sharepoint

http://YOUR_SERVER_URL/PATH_TO_SITE_CONTAINING_LIST/_vti_bin/owssvr.dll?Cmd=ExportList&List={YOUR_LIST_GUID}

Paging on SQL Server 2012
SQL Server 2008-   Paging by row_number() function:
declare @JobID varchar(max);
declare @JobName nvarchar(max);
declare @CompanyName nvarchar(max);
declare @DataSource nvarchar(max);
declare @JobCategory nvarchar(max);
declare @Area nvarchar(max);
declare @PageIndex int;
declare @PageSize int;

set @PageIndex=1;
set @PageSize=20;

select
    d.*
from
(
    select
        ROW_NUMBER() over(order by JobName asc) RowIndex,  -- sortField, sortOrder
        v.*
    from JobDataView v
    inner join
    (
        select distinct JobID
        from JobDataSheet
        where
            (@JobID is null or JobID=@JobID)
        and (@JobName is null or JobName like '%'+@JobName+'%')
        and (@CompanyName is null or CompanyName like '%'+@CompanyName+'%')
        and (@DataSource is null or DataSource=@DataSource)
        and (@JobCategory is null or CategoryName=@JobCategory)
        and (@Area is null or (InfoName='Area' and InfoValue like '%'+@Area+'%'))
    ) s on s.JobID=v.JobID
) d
where d.RowIndex > (@PageIndex-1)*@PageSize and d.RowIndex <= @PageIndex*@PageSize;
SQL Server 2012   Paging by offset|fetch:
declare @JobID varchar(max);
declare @JobName nvarchar(max);
declare @CompanyName nvarchar(max);
declare @DataSource nvarchar(max);
declare @JobCategory nvarchar(max);
declare @Area nvarchar(max);
declare @PageIndex int;
declare @PageSize int;

set @PageIndex=1;
set @PageSize=20;

select
    v.*
from JobDataView v
inner join
(
    select distinct JobID
    from JobDataSheet
    where
        (@JobID is null or JobID=@JobID)
    and (@JobName is null or JobName like '%'+@JobName+'%')
    and (@CompanyName is null or CompanyName like '%'+@CompanyName+'%')
    and (@DataSource is null or DataSource=@DataSource)
    and (@JobCategory is null or CategoryName=@JobCategory)
    and (@Area is null or (InfoName='Area' and InfoValue like '%'+@Area+'%'))
) s on s.JobID=v.JobID
order by v.JobName asc
offset (@PageIndex-1)*@PageSize rows
fetch next @PageSize rows only
reference : http://msdn.microsoft.com/en-us/library/ms188385%28v=SQL.110%29.aspx
Web.config setting of mvc
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" /><modules runAllManagedModulesForAllRequests="true">
            <remove name="ScriptModule" />
            <remove name="UrlRoutingModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated" />
            <remove name="ScriptHandlerFactory" />
            <remove name="ScriptHandlerFactoryAppServices" />
            <remove name="ScriptResource" />
            <remove name="MvcHttpHandler" />
            <remove name="UrlRoutingHandler" />
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </handlers>
  </system.webServer>
Batch insert using SqlDataAdapter
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["JobHunter"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connStr))
{
    conn.Open();

    #region
    string JobID = Guid.NewGuid().ToString();
    HashSet<string> JobCategory = new HashSet<string>(new string[] { 
       "Windows 8標準搭載のセキュリティ Windows Defenderとは - トレンドマイクロ",
        "Windows 8対応 パスワードマネージャー Modern UI版 - トレンドマイクロ",
        "Windows 8にもマルウェア対策は必須 - トレンドマイクロ",
        "Windows 8にもWeb脅威対策は必須 - トレンドマイクロ",
        "Windows 8でも、面倒なパスワード入力はしない。 - トレンドマイクロ",
        "Windows 8 最新のセキュリティにも対応 - トレンドマイクロ",
        "Windows 8 もウイルスバスタークラウドで安心! border=",
        "Windows 8 のセキュリティ対策もウイルスバスター クラウド - トレンドマイクロ",
        "Windows 8 Modern UI向け無料アプリ Windows ストアアプリ",
        "Windows 8 Modern UI向け Windows ストアアプリ - トレンドマイクロ",
        "Windows 8 Modern UI向け 3種類のWindows ストアアプリ - トレンドマイクロ"
    });
    #endregion

    using (System.Data.SqlClient.SqlDataAdapter adapter 
        = new System.Data.SqlClient.SqlDataAdapter(@"select top 0 * from JobCategory", conn))
    {
        // add insert command
        adapter.InsertCommand = new SqlCommand(@"insert into JobCategory values(@JobID, @CategoryName);", conn);
        adapter.InsertCommand.Parameters.Add("@JobID", SqlDbType.VarChar, 50, "JobID");
        adapter.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 50, "CategoryName");
        adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;

        DataTable dt = new DataTable();
        adapter.Fill(dt);

        foreach (string name in JobCategory)
        {
            dt.Rows.Add(JobID, name);
        }

        // one-time update
        adapter.UpdateBatchSize = 0;
        adapter.Update(dt);
    }
}