25 Haziran 2012 Pazartesi

error: LINQ to Entities does not recognize the method ...Last

The complete error message is as follows :


{"LINQ to Entities does not recognize the method 'Core.Sentence Last[Sentence (System.Collections.Generic.IEnumerable`1[Core.Sentence])' method, and this method cannot be translated into a store expression."}

and the causing line is:


retList = (dal.Paragraph.Include("Sentence").Where(p => p.Sentence.Last().Topic.ID == topic.ID)).ToList();

This is because Last and LastOrDefault are just not supported by the LINQ to SQL query translator.
http://forums.asp.net/t/1480557.aspx/1

The solution is ordering Sentence in descending order and use FirstOrDefault instead of Last:

 retList = (dal.Paragraph.Include("Sentence").Where(p => p.Sentence.OrderByDescending(s => s.ID).FirstOrDefault().Topic.ID == topic.ID)).ToList();


codefirst inheritance strategies

I am in the .net world  for a while and bumped into several technical problems so far. I plan to post the problems with their solutions when i have time for this. I also want to write a post comparing .net and java platforms. For now, it is enough to state that i am a java fan..

http://romiller.com/2010/09/29/ef-ctp4-tips-tricks-code-first-inheritance-mapping/  is an article about how codefirst handles inheritance during table generation. To sum up, default table generation strategy is Table-per-Hierarchy (TPH) which keeps all data in one table created for the base type and automatically creates a Discriminator field in order ro discriminate different types. Table-per-Type (TPT) creates a table for the base type with shared columns and different tables for each derived type whereas Table-per-Concrete Class(TPC) creates an entirely different table for each class.. However, when the table generation strategy is modified, previously working code may start to blow up.. Moreover, performance is best when the default strategy (TPH) is used: http://blogs.msdn.com/b/adonet/archive/2010/08/17/performance-considerations-when-using-tpt-table-per-type-inheritance-in-the-entity-framework.aspx

29 Mayıs 2012 Salı

trac on windows

Trac (http://trac.edgewall.org/) is my favorite issue tracking tool. However, installing trac on windows is not a straightforward task. The easiest way to achieve this is by using bitnami.. .http://bitnami.org/download/files/stacks/trac/0.12.3-0/bitnami-trac-0.12.3-0-windows-installer.exe
Just run the exe, specify a port for trac, specify a project name and enjoy yourself..

22 Nisan 2012 Pazar

two useful online tools

an online free tool for merging multiple pdf files into one: http://foxyutils.com/mergepdf/

an online image conversion tool: http://www.go2convert.com/

8 Nisan 2012 Pazar

numbered list in Latex

Here is a way of creating numbered lists in Latex:



\begin{enumerate}
\item bla
\begin{enumerate}
\item bla bla
\item bla bla bla
\end{enumerate}
\item bla bla bla bla
\item bla bla bla bla bla 
\end{enumerate}