Thursday, September 3, 2015

Rename Column

Use DBName
go


EXEC sp_rename '.dbo.Table.oldColumnName', 'NewColumnName', 'COLUMN'


-NewColumnName no need Tables or any . []

Tuesday, September 1, 2015

WF Errors

Error Message
Literal<Boolean>' is not of type 'Delay'. When loading this instance you must ensure that the activity with name 'Literal<Boolean>

Solve: It might be CorrelationID is null

Sunday, July 19, 2015

Q & A

A. 
It compiles your code into a .NET Assembly
B. 
It provides access to Microsoft’s library of code
C. 
It provides a common type system for your application
D. 
It is what your program runs inside of ... it protects the user from malicious code, and handles memory management and other runtime tasks
A. 
A block of code
B. 
A method
C. 
A function
D. 
A variable
A. 
A way to restrict access to your code
B. 
A named block of code that you can call / execute by calling its name
C. 
A means of organizing your code
A. 
A .NET Package
B. 
A .NET Component
C. 
A .NET
D. 
A .NET Assembly
A. 
An XML that contains project settings and the current state of the project
B. 
A file that contains all the C# code
C. 
A file that contains C# code containing project settings, files to include in the project, etc.
D. 
An XML file that contains information about all the project in a given solution

Monday, June 22, 2015

Find Gridview Row From List and check it.

foreach (var item in listPeople)
{
 var row = gvAddPeople.Rows.Cast<GridViewRow>()
.Where(x => ((HiddenField)x.Cells[0].Controls[3]).Value == item.PeopleID.ToString()).Single();

 ((CheckBox)row.Cells[0].Controls[1]).Checked = true;
}

Monday, June 1, 2015

Advanced LINQ

Get same attribute between 2 List

var listPerson = AlllistPerson.Where(x => listPhone
 .Any(y => x.PersonPhone.Contains(y.PhoneNmbers).ToList();

Remove from another List (duplicate)

var result = personList.Where(c => !transactionList.Exists(b => c.phone == b.phone)).ToList();

Remove from another List (duplicate) & Child List


List<long> phoneNumbers = sessionTelco.SelectMany
                            (x => x.PhoneList.Select(y => y.phone)).ToList();

coveragePrices = coveragePrices.Where(x => ! phoneNumbers.Contains(x. phone)).ToList();

Selecting First Item from every group

var grouped = personList.GroupBy(x => x.CountryName).Select(y => y.First()).ToList();

 var grouped = from x in personList
            group x by x.CountryName
            into y
            select y.First();


select many from child list.


List<long> routeClassIDList = _upc.SessionClientGroupList.SelectMany
         (x => x.ClientGroupCoverageList.Select(y => y.RouteClassID)).ToList();


filter all child list same with list


clientGroups = clientGroups.Where(x => !x.ClientGroupCoverageList.All(y => routeClassIDList.Contains(y.RouteClassID))).ToList();


ForEach Add if else


people.ForEach(x => { if (x.Balance.HasValue == false || x.Balance.Value == 0) x.Balance = null; });


INNER JOIN 
devicePerAccList = (from f in devicePerAccList
                    join s in Accounts on f.AccountId equals s.E2AccountId
                    select new DevicePerAcc
                    {
                        AccountId = f.AccountId,
                        AccCode = s.AccountCode,
                        NoOfDevice = f.NoOfDevice

                    }).ToList();

Select Many, Find Description, Filter Description = null, Order By 1A , 2B , 11A

preBookMealList = ssrReportList.SelectMany(a => a.SSRCodes.Select(b => new PreBookMeal
{
SSRCode = b,
SSRDescription = ssrMealList.Where(c => c.SSRCode == b).Select(d => d.Name).FirstOrDefault()
})
.Where(e => e.SSRDescription != null))
.OrderBy(f => int.Parse(f.SeatNo.Remove(f.SeatNo.Length - 1)))
.ToList();


Dictionary put Key to object ID

result = peopleList.Select(x => { x.Value.peopleID = x.Key; return x.Value; }).ToList();

Saturday, April 11, 2015

Bootstrap

HTML - CSS - JavaScript
Make sure to add jQuery file above the bootstrap file.

<div class="container-fluid">
Full width container

<div class="container">
Fixed width container

btn Modifier
–Default
–Primary
–Success
–Info
–Warning
–Danger

Saturday, April 4, 2015

Parse XML File


  1. Reference System.XML
  2. Use XmlReader to parse the text string
  3. Use XmlReader to read the xml data

string xmlString =
                @"<bookstore>
                    <book genre='autobox' publishDate='2015-03-04'>
                        <title>Many bottle</title>
                        <author>
                            <firstName>David</firstName>
                            <lastName>Baby<lastName>
                        </author>
                    </book>
                  </bookstore>";

StringBuilder result = new StringBuilder();

using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
{
   reader.ReadToFollowing("book");
   reader.MoveToFirstAttribute();
   string genre = reader.Value;
   result.AppendLine("Genre value :" + genre);

   reader.ReadToFollowing("title");
   result.AppendLine("title element :" + reader.ReadElementContentAsString());
}

Console.Write(result);