CultureInfo ci = CultureInfo.CreateSpecificCulture(prefix);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
Tuesday, January 31, 2012
XDcoument Linq to AXML
public class FeedDefintion
{
public string State { get; set; }
public string Zip { get; set; }
}
public void ProcessRequest(HttpContext context)
{
//write your handler implementation here.
XDocument xdoc = XDocument.Load(context.Server.MapPath("Listings.xml"));
var feeds = from feed in xdoc.Descendants("Categories")
select new FeedDefintion { State = feed.Element("State").Value, Zip = feed.Element("Zip").Value };
List fl = feeds.ToList();
System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(fl);
//context.Response.ContentType = "application/json";
context.Response.ContentType = "application/json";
sJSON = context.Request.QueryString["callback"] + "(" + sJSON + ");";
context.Response.Write(sJSON);
}
{
public string State { get; set; }
public string Zip { get; set; }
}
public void ProcessRequest(HttpContext context)
{
//write your handler implementation here.
XDocument xdoc = XDocument.Load(context.Server.MapPath("Listings.xml"));
var feeds = from feed in xdoc.Descendants("Categories")
select new FeedDefintion { State = feed.Element("State").Value, Zip = feed.Element("Zip").Value };
List
System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(fl);
//context.Response.ContentType = "application/json";
context.Response.ContentType = "application/json";
sJSON = context.Request.QueryString["callback"] + "(" + sJSON + ");";
context.Response.Write(sJSON);
}
Monday, January 30, 2012
Sunday, January 22, 2012
Creates an instance of the specified type
Activator class is extremely powerful:
Contains methods to create types of objects locally or remotely, or obtain references to existing remote objects.
Activator.CreateInstance
Contains methods to create types of objects locally or remotely, or obtain references to existing remote objects.
Activator.CreateInstance
Hashtable v. Dictionary
The Dictionary(Of TKey, TValue) and ConcurrentDictionary(Of TKey, TValue)classes have the same functionality as the Hashtable class. A Dictionary(Of TKey, TValue) of a specific type (other than Object) provides better performance than a Hashtable for value types. This is because the elements of Hashtable are of type Object; therefore, boxing and unboxing typically occur when you store or retrieve a value type. The ConcurrentDictionary(Of TKey, TValue)class should be used when multiple threads might be accessing the collection simultaneously.
Saturday, January 14, 2012
WCF Notes
The Svcutil.exe tool can be used only with XML Schema (XSD) files that support data contracts. If data contracts cannot be generated, you must use the Xsd.exe tool to generate XML-based data types from the XSD file.
Use SVCUtil.exe and not XSD.exe. Must read article:
http://blog.shutupandcode.net/?p=761
Validate XML with SoapExtension:
http://msdn.microsoft.com/en-us/magazine/cc164115.aspx
Use SVCUtil.exe and not XSD.exe. Must read article:
http://blog.shutupandcode.net/?p=761
Validate XML with SoapExtension:
http://msdn.microsoft.com/en-us/magazine/cc164115.aspx
Thursday, January 12, 2012
SQL Notes
Find all references of a given stored proc or a given string.
syscomments has the body text for all user stored procs in the system.
So you may search all stored procs that contain a given text.
Suppose you want to see all references for a stored proc named up_MyProc.
You may accomplish this as follows:
declare @keyword nvarchar(100)
set @keyword = 'up_MyProc' -- Enter the key word here like 'OptInInd'
SELECT distinct 'sp_helptext ' + o.name
FROM syscomments s, sys.objects o
where s.id = o.object_id
and o.type = 'P'
and charindex(@keyword, s.text) > 0
******
syscomments has the body text for all user stored procs in the system.
So you may search all stored procs that contain a given text.
Suppose you want to see all references for a stored proc named up_MyProc.
You may accomplish this as follows:
declare @keyword nvarchar(100)
set @keyword = 'up_MyProc' -- Enter the key word here like 'OptInInd'
SELECT distinct 'sp_helptext ' + o.name
FROM syscomments s, sys.objects o
where s.id = o.object_id
and o.type = 'P'
and charindex(@keyword, s.text) > 0
******
The syntax for using an alias in an update statement on SQL Server is as follows:
UPDATE QSET Q.TITLE = 'TEST'
FROM HOLD_TABLE QWHERE Q.ID = 101;
So one could write and update based on selected rows:
update pv
set pv.[LocalizedText]= (Select [LocalizedText] from [Np2n.v2.eCoCommon].[dbo].[LocalizationItem] as nv
where nv.[LocalizationItemID]='NP_Review_ShipMethod_Header' and
nv.cultureid=pv.cultureid) from [Np2n.v2.eCoCommon].[dbo].[LocalizationItem] pv where pv.[LocalizationItemID]='GG_Review_ShipMethod_Header'
******
Mutliple insert from another source:
INSERT INTO Store_Information (store_name, Sales, Date)
SELECT store_name, Sales, Date
FROM Sales_Information
WHERE Year(Date) = 1998
Subscribe to:
Posts (Atom)