Unfortunately, when using automatically generated ID s in database, it is not possible to get the ID before doing SaveChanges().
http://stackoverflow.com/questions/6029711/id-of-newly-added-entity-before-savechanges/6029864#6029864
29 Haziran 2012 Cuma
how to write content of dictionary to file
In order to write the content of a dictionary to a file:
http://stackoverflow.com/questions/3067282/how-to-write-the-content-of-a-dictionary-to-a-text-file
public static void writeDictToFile(Dictionary dict, string filename) {
File.WriteAllLines(filename + ".txt",
dict.Select(x => "[" + x.Key + " " + x.Value + "]").ToArray());
}
http://stackoverflow.com/questions/3067282/how-to-write-the-content-of-a-dictionary-to-a-text-file
27 Haziran 2012 Çarşamba
html vertical line
Unfortunately, there is no explicit element in html in order to draw a vertical line .. However, there are 3 ways to achieve this:
1) With table column: http://stackoverflow.com/questions/3148415/how-to-make-a-vertical-line
<td width="5%"style="border-left: 1px solid black; padding: 5px;"> </td>
2) With 1-pixel image
3) With css (div)
for 2 and 3 : http://w3cyberlearning.com/html/html_vertical_line.php
Another option is to draw very thick and short horizontal line: http://forum.yola.com/yola/topics/vertical_lines_using_html
25 Haziran 2012 Pazartesi
error : The underlying connection was closed: The connection was closed unexpectedly.
If the error
{"The underlying connection was closed: The connection was closed unexpectedly."}
blows up for some of the web service methods, while others work correctly, the reason may be the return objects refer to each other in a recursive manner.
In my condition, i got the error while returning Sentence.
Paragraph() {
List<Sentence> Sentence;}
Sentence() {
List<Paragraph> SomeText;
}
When the type of SomeText is changed from Paragraph to Sentence, everything works fine!
error: LINQ to Entities does not recognize the method ...Last
The complete error message is as follows :
and the causing line is:
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:
{"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
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
.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
Kaydol:
Kayıtlar (Atom)