Browse by Tags
All Tags »
C# 3.0 »
Linq (
RSS)
I've blogged before (in hebrew) about the difficulty of serializing expression trees to XML. To conclude my hebrew post, I've found a project in CodePlex, called MetaLinq which might be the solution to the problem - this open source allows to perform Linq queries over expression trees, and as a consequence, might allow serialization of the navigable expression tree. I've worked in past few days to fix the code of the project to allow serializing the tree with DataContractSerializer. The...
I've received a couple of request to write some of my previous posts in English so that all other 99.7% of the developers community in the world which finds these subjects interesting can understand what I'm writing. The following post is a translation to English of this Hebrew post . When Entity Framework (EF for short) was designed, Microsoft decided the loading of entities will be during run-time in a JIT like mechanism. They achieved this by using the lazy loading technique - access the...
אחד מהדברים השימושיים ב-3.0 #C, אע"פ שהוא מעט הוזנח במצגות השונות, הוא עץ הביטויים (Expression Tree) שהוא הדבק שמחבר את Lambda Expressions ו-Linq. מאחר ובאמצעות Expression Tree אפשר לייצג ביטוי לוגי, מצאתי לו שימוש במערכת בה הביטויים הלוגיים הם דינאמיים, המבנה שלהם נשמר ב-DB והם צריכים להיבנות ולהיבדק בזמן ריצה. אבל... בדבר אחד Expression Tree נכשל - אי אפשר לבצע לו סריאליזציה. הדבר מוסבר בפורומים השונים, כדוגמת כאן , והסיבות נשמעות די הגיוניות: המחלקות השונות של Expression Tree מכילות מאפיינים...
ברצוננו לכתוב מתודה אשר תקבל שם קובץ חדש ורשימת קבצים בתיקייה ותחזיר שם קובץ תקין שאינו קיים בתיקייה (כמו שיצירת קובץ חדש בתיקייה תחת וינדוס יוצרת קבצים בשם "new", "new1", "new2" וכו'). string GetUniqueFileName(List<File> files, string newFileName) נוכל לכתוב מתודה אשר עוברת על רשימת הקבצים בתיקייה (List כלשהו) ומחפשת עפ"י מאפיין שם קובץ (obj.FileName) אם השם תפוס ואם כן, להוסיף לשם שהועבר איזשהו Suffix ולנסות שוב עד למציאת שם תקין. עכשיו בואו נסבך - נניח...