Thursday, December 6, 2012

Azure - The target "PipelineTransformPhase" does not exist in the project.

Issue:

When performing a build you may receive the following error.

Error:

error MSB4057: The target "PipelineTransformPhase" does not exist in the project.

Solution:

Either the path is wrong in your .csproj file or your missing the Microsoft.WebApplication.Targets file on your build server.

If its missing on your build server simply just copy it over from your local machine, from and to the same location.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications

Friday, November 9, 2012

LINQ - The data source does not support server-side data paging.

Issue:

When trying to bind a result set to a gridview from a LINQ query you may receive the following error.

gridView.DataSource = results;


Error:

The data source does not support server-side data paging.


Solution:

Chances are you just need to add a .ToList() on your return var from your LINQ query. A common case is when you use .Intersect on lists and forget to do another .ToList().

Friday, October 5, 2012

Copy SQL to Excel Missing Rows


Issue:

When you try to copy rows from SQL server and paste into Excel but experience missing rows either by right clicking and coping with headers or saving as a CSV.

Solution:

The problem is double quotes "

Excel will skip all rows in between the start and end of a double quotes.

1) Either trim off the quotes in SQL

or

2) Right click and save as text, tab delimited, from SQL and then open in Excel using the default workflow selections during import.

Wednesday, October 3, 2012

Ajax Control Toolkit - Programmatically expand CollapsiblePanelExtender


Issue:
Expand a collapsible panel programmatically with use of a button or linkbutton other than the already assigned ExpandControlID control.



Solution: 
protected void expandCollapsiblePanelButton_Click(object sender, EventArgs e)
{
    // expand
    testCollapsiblePanelExtender.Collapsed = false;
    testCollapsiblePanelExtender.ClientState = "false";
}

Tuesday, April 3, 2012

LINQ - Distinct() not working as expected

Issue: 

When using custom classes not generated by LINQ to SQL, Distinct() is unable to determine that two objects might be the same based on a key or all values within the objects, and simply sees two different objects regardless.

Solution:

Distinct() has an overload which takes an IEqualityComparer, thus allowing you to specify the value or values in which to compare and determine uniqueness upon.

Ex: For simplicity, lets say the list of clients passed in has duplicates. OID is organization id, and CID is client id.


            public static IEnumerable<CustomClient> GetClientsByOrganizationID(IEnumerable<CustomClient> clients, int oid)
            {
                using (DataContext db = new DataContext())
                {
                    db.DeferredLoadingEnabled = false;

                    var query = from c in clients
                                join o in db.Organizations on c.OID equals o.OID
                                where o.OID == oid
                                select c;

                    return query.Distinct(new ClientComparer()).ToList();
                }
            }


            public class ClientComparer : IEqualityComparer<CustomClient>
            {
                public bool Equals(CustomClient x, CustomClient y)
                {
                    return x.CID == y.CID;
                }

                public int GetHashCode(CustomClient obj)
                {
                    return obj.CID.GetHashCode();
                }
            }