![]() |
| Killarney, Co.Kerry 2011-02-19 |
Monday, February 21, 2011
Monday, February 7, 2011
ASP.NET LINQ Union Distinct not working
Using Union(....).Distinct() not producing a distinct list when unioning a list of complex objects.
CAUSE:
Union() and Distinct() don't know which member of the object to use in their comparisons.
SOLUTION:
1. - IEqualityComparer needs to be defined to specify what fields of the object to compare:
public class MyComplexObjectComparer : IEqualityComparer
{
public bool Equals(complexObject a, complexObject b)
{
return a.Id == b.Id;
}
public int GetHashCode(complexObject obj)
{
return obj.Id.GetHashCode();
}
}
2. - Pass this comparer into the Union:
.Union(lockedout, new MyComplexObjectComparer()).Distinct;
SOURCE:
http://blog.dreamlabsolutions.com/post/2009/06/23/Enumerable-Except-TSource-and-IEqualityComparer-a-little-help.aspx
CAUSE:
Union() and Distinct() don't know which member of the object to use in their comparisons.
SOLUTION:
1. - IEqualityComparer needs to be defined to specify what fields of the object to compare:
public class MyComplexObjectComparer : IEqualityComparer
{
public bool Equals(complexObject a, complexObject b)
{
return a.Id == b.Id;
}
public int GetHashCode(complexObject obj)
{
return obj.Id.GetHashCode();
}
}
2. - Pass this comparer into the Union:
.Union(lockedout, new MyComplexObjectComparer()).Distinct;
SOURCE:
http://blog.dreamlabsolutions.com/post/2009/06/23/Enumerable-Except-TSource-and-IEqualityComparer-a-little-help.aspx
Thursday, January 27, 2011
IIS 6 Error - Port in use when binding a wildcard SSL to multiple sites
Port in use error occurs when 443 is set as SSL port on multiple site in IIS 6.
CAUSE:
SecureBindings metabase property is not set.
SOLUTION:
Run the following from cmd:
C:\Inetpub\AdminScripts\cscript.exe adsutil.vbs set /w3svc/SITEIDENTIFIER/SecureBindings ":443:HOSTHEADER"
where SITEIDENTIFIER and HOSTHEADER are replaced.
SOURCE:
http://www.sslshopper.com/article-how-to-configure-ssl-host-headers-in-iis-6.html
CAUSE:
SecureBindings metabase property is not set.
SOLUTION:
Run the following from cmd:
C:\Inetpub\AdminScripts\cscript.exe adsutil.vbs set /w3svc/SITEIDENTIFIER/SecureBindings ":443:HOSTHEADER"
where SITEIDENTIFIER and HOSTHEADER are replaced.
SOURCE:
http://www.sslshopper.com/article-how-to-configure-ssl-host-headers-in-iis-6.html
Photoshop CS4 – Fix : Error: 148:3
POSSIBLE CAUSE:
Flexnet Licensing Service not running
SOLUTION:
- Start->Run, type services.msc
- Find Flexnet Licensing Service and right-click
- Click Start if possible, otherwise click Properties, and set service to run automatically.
Source:
http://forums.adobe.com/thread/375447
Flexnet Licensing Service not running
SOLUTION:
- Start->Run, type services.msc
- Find Flexnet Licensing Service and right-click
- Click Start if possible, otherwise click Properties, and set service to run automatically.
Source:
http://forums.adobe.com/thread/375447
Sunday, January 23, 2011
Wednesday, January 5, 2011
Wednesday, December 15, 2010
Earth Temperature Increases Mapped
Nasa's GISS Temperature Map:
Source:
http://earthobservatory.nasa.gov/Features/WorldOfChange/decadaltemp.php?src=eoa-features
Sunday, December 5, 2010
Friday, December 3, 2010
ASP.NET Datasets: Failed to enable constraints.
Got this error after changing the length of a column in the database:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
CAUSE:
The table adapter column maxlength is not updated automatically.
SOLUTION:
Update the table adapter column maxlength manually in the properties window for that column in the dataset editor.
Source:
http://social.msdn.microsoft.com/Forums/en/Vsexpressvb/thread/27aec612-5ca4-41ba-80d6-0204893fdcd1
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
CAUSE:
The table adapter column maxlength is not updated automatically.
SOLUTION:
Update the table adapter column maxlength manually in the properties window for that column in the dataset editor.
Source:
http://social.msdn.microsoft.com/Forums/en/Vsexpressvb/thread/27aec612-5ca4-41ba-80d6-0204893fdcd1
Sunday, November 21, 2010
Thursday, November 18, 2010
Wednesday, November 17, 2010
SQL SERVER – Fix : Error: 4064
SQL SERVER 2005 – Fix : Error: 4064 – Cannot open user default database. Login failed. Login failed for user.
CAUSE:
The default database for the user is not accessible, this stops the user from logging in.
SOLUTION:
- Login Prompt->Connection Properties Tab->Connect to database field
- Change the database name to master.
- Once logged in, update the user's default database:
ALTER LOGIN [user] WITH DEFAULT_DATABASE = master
Source:
http://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/
CAUSE:
The default database for the user is not accessible, this stops the user from logging in.
SOLUTION:
- Login Prompt->Connection Properties Tab->Connect to database field
- Change the database name to master.
- Once logged in, update the user's default database:
ALTER LOGIN [user] WITH DEFAULT_DATABASE = master
Source:
http://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/
Friday, November 5, 2010
Tuesday, November 2, 2010
Flush Photoshop CS4 preferences when freezing on startup
If Photoshop CS4 freezes on startup, or opens off-screen (into a multiple monitor ghost), you can flush the user preferences by renaming the preferences file:
C:\[User]\AppData\Roaming\Adobe\Adobe Photoshop CS4\Adobe Photoshop CS4 Settings\Adobe Photoshop CS4 Prefs.psp
Source:
http://www.wallpaperama.com/disp-post57.html
C:\[User]\AppData\Roaming\Adobe\Adobe Photoshop CS4\Adobe Photoshop CS4 Settings\Adobe Photoshop CS4 Prefs.psp
Source:
http://www.wallpaperama.com/disp-post57.html
Tuesday, September 21, 2010
Sunday, September 19, 2010
Tuesday, September 14, 2010
Using LINQ to get a Distinct List
First, create a type comparer:
Then, use it as follows on a List- items:
public class ItemComparer : IEqualityComparer<Item> { #region IEqualityComparer<Item> Members public bool Equals(Item x, Item y) { return x.ItemID == y.ItemID; } public int GetHashCode(Item obj) { return obj.ItemID.GetHashCode(); } #endregion }
Then, use it as follows on a List
IEnumerable<Item> distinctItems =
items.Distinct(new ItemComparer()); items = distinctItems.ToList();
Sunday, September 5, 2010
Subscribe to:
Posts (Atom)







