Thursday, October 09, 2008

Linq: Split string array and convert into integer using a converter / lambda and then selecting where in or contains from that list

// This will split an CSV string array into an array of integers
int[] intArr = Array.ConvertAll( priorityCsv.Split(','), n => Convert.ToInt32(n) );

//This will select the count of values where there are in or contain the values in the array
return (from v in this.Context.VACompanyErrors where intArr.Contains(v.Priority) select v).Count();

Tuesday, May 20, 2008

fill text box with nullable type or empty

fill text box with nullable type or empty
txtExpectedCloseDateTextBox.Text = olo.ExpectedCloseDate.ToString() ?? string.Empty;

Friday, April 25, 2008

iterate

list.ForEach(delegate(MyType x) { x.Property1.Replace("AAAA", "").Replace("BBBB", ""); });
OneType one = OneTypeList.Find(delegate(OneType ooo) { return oood.Value == "findstring; });

Wednesday, February 13, 2008

table with infinite dynamically expandable columns veritcal rows propertes attributes eav otlt

If you need to have a table with attributes(columns) that need to be added dynamically, consider going vertically. There are various methods to add attributes to an entity by adding the attributes as rows.

you may be looking for these (Google them):

Entity-Attribute-Value model
“OTLT” (One True Lookup Table)
vertical model
vertical database
row modeling
attribute value system
sql_variant

Think deeply before you use any of these. Be careful you don't end up with a mess.
Resources:
Dave’s guide to the EAV

OTLT and EAV: the two big design mistakes all beginners make

Entity-Attribute-Value (EAV) model with SQL Server 2005 xml datatype

An Introduction to Entity-Attribute-Value Design for Generic Clinical Study Data Management Systems

Entity-Attribute-Value model

Explanation of many database models including EAV

-Dwight