Register
Sunday, February 05, 2012
 
 DBAs And ProgrammersBlog
  
News! Minimize
   
 
 Print   
 
Misc Blog Stuff Minimize
   
 
 Print   
 
The Reluctant DBA Minimize
 
 
 
 Print   
 
Reluctant DBA Minimize
   
 
  
 
Reluctant DBA Minimize
   
 
  
 
The Reluctant DBA Minimize
 
Dec3

Written by:CarpDeus
12/3/2008 11:13 AM 

If you want to add tags to a cached item, it's as simple as including an array of Tag objects to your cache call. If you want to create that array, well, that's a little more difficult. You have to create each individual Tag object and add them to the array. It'd be nice to be able to pass in an array of strings and get an array of Tags, so I've got a helper function to do just that:

/// <summary>
/// Turn a delimited string list into an array of tags
/// </summary>
/// <param name="TagList">Delimited string list</param>
/// <param name="Delimiter">Delimiter for the list</param>
/// <returns>Array of tags</returns>
private Tag[] SplitTags(string TagList, char Delimiter)
{
Array buildList = Array.CreateInstance(typeof(Tag),TagList.Split(Delimiter).GetUpperBound(0)+1);
int i = 0;
foreach (string TagValue in TagList.Split(Delimiter))
{
buildList.SetValue(new Tag(TagValue), i++);
}
return (Tag[]) buildList;
}

 If anyone comes across another way to do this, please let me know.

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
 
 
  
 
Privacy Statement | Terms Of Use Copyright 2001-2008 by ReluctantDBA.com