Monthly Archives: August 2014

C# check if a string contains an element from a collection

List of strings

if(listOfStrings.Any(s => myString.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0))
    result = listOfStrings[myString];

Dictionary, accessing string as a Key

if(dictionaryOfStrings.Keys.Any(c => myString.IndexOf(c, StringComparison.OrdinalIgnoreCase) > 0))
    result = dictionaryOfStrings[myString];

Dictionary, accessing string as a Value

if(dictionaryOfStrings.Values.Any(c => myString.IndexOf(c, StringComparison.OrdinalIgnoreCase) > 0))
    foreach (KeyValuePair<string, string> pair in dictionaryOfStrings)
        if (myString.Equals(pair.Value))
            result = pair.Key;

Windows Firewall: How to allow all traffic from 1 IP address

Control panel > Windows Firewall > Advanced Settings (in the left side panel). This Opens up an mmc window for advanced firewall configuration.
In the left panel, choose Inbound or Outbound rules.
Right panel, click New rule.
In the dialog, choose “custom”.
In the left again, go to “Scope.” When you add an IP, you can add a range.

For the Remote IP address enter which is localhost.


via Super User

SQL Find all references to a table

You can use multiple approaches using SQL query like one below.
For me the fastest way to use SQL Search from Red Gate and from Objects filter select ‘Tables’

SELECT AS FK_NAME, AS [schema_name], AS [table], AS [column], AS [referenced_table], AS [referenced_column]
FROM sys.foreign_key_columns fkc
INNER JOIN sys.objects obj
    ON obj.object_id = fkc.constraint_object_id
INNER JOIN sys.tables tab1
    ON tab1.object_id = fkc.parent_object_id
INNER JOIN sys.schemas sch
    ON tab1.schema_id = sch.schema_id
INNER JOIN sys.columns col1
    ON col1.column_id = parent_column_id AND col1.object_id = tab1.object_id
INNER JOIN sys.tables tab2
    ON tab2.object_id = fkc.referenced_object_id
INNER JOIN sys.columns col2
    ON col2.column_id = referenced_column_id AND col2.object_id = tab2.object_id

via Stack Overflow