Aklımda Kalası Kelimeler

* давайте работать вместе
* Zarf ve Mazruf, Zerafet(xHoyratlık) ile aynı kökten(za-ra-fe) gelir
* Bedesten
* Suç subuta ermiştir - Suç sabit olmuştur

22 Şubat 2010 Pazartesi

ASP.NET Web Site Paths

http://msdn.microsoft.com/en-us/library/ms178116.aspx

An absolute URL path. An absolute URL path is useful if you are referencing resources in another location, such as an external Web site.


<img src="http://www.contoso.com/MyApplication/Images/SampleImage.jpg" />



A site-root relative path, which is resolved against the site root (not the application root). Site-root relative paths are useful if you keep cross-application resources, such as images or client script files, in a folder that is located under the Web site root.

This example path assumes that an Images folder is located under the Web site root.


<img src="/Images/SampleImage.jpg" />



If your Web site is http://www.contoso.com, the path would resolve to the following.


http://www.contoso.com/Images/SampleImage.jpg



A relative path that is resolved against the current page path.


<img src="Images/SampleImage.jpg" />



A relative path that is resolved as a peer of the current page path.


<img src="../Images/SampleImage.jpg" />

16 Şubat 2010 Salı

ASP.NET te Page Error

Code Behind kısmında hata yakalama:

protected void Page_Error(object sender, EventArgs e)
{
try
{
Response.Write(Server.GetLastError().Message);
}
finally
{
Server.ClearError();
}
}


Global.asax ta hata yakalama:

protected void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception objErr = Server.GetLastError().GetBaseException();
string err = "Error in: " + Request.Url.ToString() +
". Error Message:" + objErr.Message.ToString();

}

14 Şubat 2010 Pazar

Dizinleri TreeView içinde göstermek



<asp:TreeView ID="tvKlasorler" runat="server" ImageSet="Arrows" PathSeparator="|"
ShowCheckBoxes="Leaf" >
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
VerticalPadding="0px" />
<NodeStyle Font-Names="Verdana" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>


CODE BEHIND:

protected void Page_Load(object sender, EventArgs e)
{
TreeNode root = new TreeNode("KÖK-Root"); // EN ÜST TUTUCU

DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/"));
foreach (DirectoryInfo g in dir.GetDirectories())
{
//SVN ne Resharper klasörleri hariç
if (!f_SVNDizinimi(g) && !f_ResharperDizinimi(g) )
{
// Bu klasörü ve altındaki klasörleri Root Node'a ekle
root.ChildNodes.Add(f_GetNode(g));
}
}
tvKlasorler.Nodes.Add(root);
}

private TreeNode f_GetNode(DirectoryInfo altDizin)
{
//Bu klasörü NODE olarak oluşturalım. (Ağacın bir dalı olsun)
TreeNode tn = new TreeNode(altDizin.Name);

//Bu dalın alt dalları(klasörleri) varmı? Varsa, SVN ve RESHARPER olmayanları çekelim
DirectoryInfo[] yeniDizi = f_AltDizinleriGetir(altDizin.GetDirectories());

//Eğer alt dalları yoksa bir üst dala eklenmek üzere geri gönderelim
if (yeniDizi.Count() == 0)
{
return new TreeNode(altDizin.Name);
}
else //Eğer alt dalları varsa
{
//Alt dalların(klasörlerin) herbirini dolaşalım ve bulunduğumuz dala ekleyelim
foreach (DirectoryInfo info in yeniDizi)
{
tn.ChildNodes.Add(f_GetNode(info));
}
return tn;
}
}

private DirectoryInfo[] f_AltDizinleriGetir(DirectoryInfo[] dirs)
{
return dirs.Where(d => ((f_Dizinmi(d) && !f_Gizlimi(d) && !f_SVNDizinimi(d) && !f_ResharperDizinimi(d)))).Select(p => p).ToArray();
}

private bool f_Dizinmi(DirectoryInfo g)
{
return ((g.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
}

private bool f_Gizlimi(DirectoryInfo g)
{
return ((g.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);
}

private bool f_SVNDizinimi(DirectoryInfo g)
{
return g.Name.Equals(".svn");
}

private bool f_ResharperDizinimi(DirectoryInfo g)
{
return g.Name.Equals("_ReSharper");
}

4 Şubat 2010 Perşembe

ODBC üzerinden MySQL bağlantı



OdbcConnection Database = new OdbcConnection("Provider=MSDASQL.1;FILEDSN=" + @"C:\blabla\file.dsn");
Database.Open();

OdbcCommand cmdSelect = new OdbcCommand("SELECT * FROM aTable", Database);

OdbcDataReader rsRecords = cmdSelect.ExecuteReader();

while(rsRecords.Read()) {
Console.WriteLine(rsRecords.GetInt32(0));
}
rsRecords.Close();

Database.Close();


file.dsn

[ODBC]
DRIVER=MySQL ODBC 3.51 Driver
UID=zosa
STMT=
OPTION=
PORT=
PASSWORD=xxxxxxxx
SERVER=localhost
DATABASE=zosa
DESC=

İleri Linq To Sql




var editorLastArticle = from article in DAO.context.GetTable()
group article by article.M_RefKoseYazariId
into g
let lastArticleDate = g.Max(x => x.M_KayitTarihi)
select new
{
Editor = g.Key,
LastArticleDate = lastArticleDate
};

var query = from article in DAO.context.GetTable()
join eal in editorLastArticle
on
new
{
article.M_RefKoseYazariId,
article.M_KayitTarihi
}
equals
new
{
M_RefKoseYazariId = eal.Editor,
M_KayitTarihi = eal.LastArticleDate
}
select new
{
article.M_YaziId,
article.M_Baslik,
article.M_Icerik,
article.M_RefKoseYazariId
};



SELECT [t0].[yazi_id] AS [M_YaziId], [t0].[baslik] AS [M_Baslik], [t0].[icerik] AS [M_Icerik], [t0].[refKoseYazari_id] AS [M_RefKoseYazariId]
FROM [Yazilar] AS [t0]
INNER JOIN (
SELECT MAX([t1].[kayitTarihi]) AS [value], [t1].[refKoseYazari_id]
FROM [Yazilar] AS [t1]
GROUP BY [t1].[refKoseYazari_id]
) AS [t2] ON ([t0].[refKoseYazari_id] = [t2].[refKoseYazari_id]) AND ([t0].[kayitTarihi] = [t2].[value])



JOIN ile ilgili güzel bir anlatımda Oğuz Yağmur'dan.

Linq ile GROUP BY ve LET kullanımı

Linq ile GROUP BY ve LET kullanımı



Context ct = new Context(cnn);
var editorsLastArticles
= from article in ct.GetTable()
group article by article.M_RefKoseYazariId
into g
let lastArticleDate = g.Max(x => x.M_KayitTarihi)
select new
{
Editor = g.Key,
LastArticleDate = lastArticleDate
};


Başka bir kaynakta: http://www.zirvedekibeyinler.net/Makaleler-237-linq-to-sql--group-by.aspx