显示标签为“LINQ”的博文。显示所有博文
显示标签为“LINQ”的博文。显示所有博文

2009年4月10日星期五

April 10th-11th Links:Velocity,C#,SQL SERVER,ReSharper

.NET
    How to optimize passing complex data to the server

ASP.NET
    1) Favicon
    2) Titles And Meta Data
    Your page title is more important element for SEO and is also important so that users know what's on the page.Make sure it changes on every page and relate to that page's content.
    3) Cross-Bowser Checks
    4) Proofread
    5) Links
    6) Graceful Degradation
    7) Validation
    8) RSS Link
    The common conversion is to put a small RSS icon in the browser's address bar.
    9) Analytics
    10) Sitemap
    Adding a sitemap.xml file to your root directory allows the major search engines to easily index your website
    11) Defensive Design
    The most commonly overlooked defensive design element is the 404 page.
    12) Optimize

C#

Javascript

Velocity
    1) High Availability
    2) Notifications
    3) Local Caching
    4) Management & Monitoriting
    5) Better Integration

WEB

IE
    1) IE8 Opens More Connections Per Host Name
    2) IE8 Has a New Process Model
    3) All IE8 Tabls,Window and Pop-ups Belong To Same Browser Session
    4) The IE8 Process Model is Configurable
    5) Compatibility Workarounds for IE8
    6) New Built-in Developer Tools For IE9
    7) How to Use HttpWatch with IE8

ReSharper

SQL SERVER
    1. Logical Query Processing Phases- Order of Statement Excution
    1) FROM -> ON -> OUTER -> WHERE -> GROUP BY-> CUBE|ROLLUP->HAVING->SELECT->DISTINCT->ORDER BY->TOP

Other
    neXpert is an add-on to Fiddler which automates the classic performance best practice checks and produces a HTML report on the issues found in a Fiddler capture.
    3.4 Great Tools to use visual Studio

2009年2月24日星期二

February 24th Links:ASP.NET,SEO,C#

ASP.NET

C#

NUint
 
LINQ-XML

SQL SERVER

WEB
    the short answer is ALWAYS! But let's rewind(绕回) a bit and provide some context...............In Summary,the compatibility(兼容) UA-X meta tag is the perfect way to ensure that your customers will enjoy your pages the way they were intended
e.g. meta equiv="x-UA-Compatible" content="IE-EmulateIE7"

CodePlex
    1. Fluent DateTime
    A set of(Ruby inspired灵感) C# Extension Methods for easier and more natural DateTime handing and operations in .NET.

English
    1. Global Summit:全球峰会
    2. Seattle and Redmond
    3. Canonical : 标准的,权威的
    4. Inspired:灵感的
    5. Campaign:战役,活动,运动

2008年10月10日星期五

XmlDocument与xelement性能(XMLDOCUMENT VS XELEMENT PERFORMANCE)

我已经使用XElement有一段时间了,下面我做了一些性能的测试,并指出在xmlDocuemnt和xelement之间的不同。
首先,XElement是.NET Framework3.5的一部分,它被使用在xml to linq,并且位于System.xml.linq命名空间下。这个class在linq方面得到了很好的使用。xElement.Nodes和xElement.Attribues返回了一个IEnumerable,这个接口很容易的被使用于nodes的访问。当然你也可以使用Lambda expressions操作它们。更多的信息请参考http//msdn.microsoft.com/en-us/library/bb487098.aspx
在下面的例子中,我创建了两个static方法,一个使用xmlDocument,一个使用xElement去生成一个XML,通过循环system assembly exported type构建一个巨大的xml ,并将其保存到Stream中去,下面是两段代码:
   1://Generates XML using XmlDocument
   2: internal static void GenerateXmlUsingXmlDocument() 
   3: {
   4:     MemoryStream ms =new MemoryStream();
   5:     XmlDocument xmlDoc = new XmlDocument();
   6:     xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no"));
   7:     XmlElement assembliesNode = xmlDoc.CreateElement("Assemblies");
   8:     foreach (Type t in Assembly.GetAssembly(typeof(Object)).GetExportedTypes())
   9:     {
  10:         XmlElement assemblyNode = xmlDoc.CreateElement("Assembly");
  11:         XmlAttribute fullTypeName = xmlDoc.CreateAttribute("FullTypeName");
  12:         fullTypeName.Value = t.ToString();
  13:         XmlAttribute isInterfaceName = xmlDoc.CreateAttribute("IsInterface");
  14:         isInterfaceName.Value = t.IsInterface.ToString();
  15:         assemblyNode.Attributes.Append(fullTypeName);
  16:         assemblyNode.Attributes.Append(isInterfaceName);
  17:         assembliesNode.AppendChild(assemblyNode);
  18:     }
  19:     xmlDoc.AppendChild(assembliesNode);
  20:     xmlDoc.WriteContentTo(new XmlTextWriter(ms,System.Text.ASCIIEncoding.ASCII));
  21: }
  22:  
  23: //Generates XML using XElement
  24: internal static void GenerateXmlUsingXElement()
  25: {
  26:     MemoryStream ms = new MemoryStream();
  27:     XElement assembliesNode = new XElement("Assemblies",
  28:             from Type t in Assembly.GetAssembly(typeof(Object)).GetExportedTypes()
  29:             select new XElement("Assembly",
  30:                 new XAttribute("FullTypeName", t.ToString()),
  31:                 new XAttribute("IsInterface", t.IsInterface.ToString())));
  32:     
  33:     assembliesNode.Save(new XmlTextWriter(ms, System.Text.ASCIIEncoding.ASCII));
  34: }
你可以发现上面两个方法中的不同了吧,xElement使用 LINQ expressions生成xml,它代码简单明了。通过下面的代码,我重复的测试在每个方法中执行时间
1: Stopwatch sw = new Stopwatch();
   2: for (int index = 0; index <>
   3: {
   4:     sw.Reset(); sw.Start();
   5:     Program.GenerateXmlUsingXmlDocument();
   6:     sw.Stop();
   7:     Console.Write("Generation time using XmlDocument " +
   8:         "and XElement: " + sw.ElapsedMilliseconds);
   9:     sw.Reset(); sw.Start();
  10:     Program.GenerateXmlUsingXElement();
  11:     sw.Stop();
  12:     Console.WriteLine(" : " + sw.ElapsedMilliseconds);
  13:     //Forcing the Garbage Collector to run to make sure,
  14:     //We dispose of all the types we created on the
  15:     //Managed heap.
  16:     GC.Collect();
  17: }
  18: Console.ReadKey();间
从上面的代码中,你可以发现我循环50次去测试每一个方法,另外,在每个测试后,我都显视的调用了GC回收器去清理通过两个方法创建的对象。下面我显示测试的结果:
XmlDocumentXElement
在上面,你可以清楚的发现,在两个方法中create xml的不同。它们之间的执行时间相差了6到10倍。在ASP.NET applications 和Web Services 中以每毫秒计算犹为重要。还有一件事情提醒一下,xElement是 .NET 3.5中Ssytem.xml.linq.dll的一部分,但是它仍桀犬吠尧是以.NET 2.0 CLR运行的,因此,如果你还没有使用.NET 3.5,你可以 copy System.Xml.Linq.dll在你的应用程序下。但是,你会错过许用来自于.NET team的好的更新。
英文地址(引用):XMLDOCUMENT VS CELEMENT PERFORMANCE