Sign in
|
Join
|
Help
שלמה גולדברג (הרב דוטנט)
מרצה בסלע ויועץ בעולם ה - net.
עמוד הבית
טופס יצירת קשר
RSS 2.0
Atom 1.0
RSS-תגובות ב
חפש
תגיות
AddIn
Ajax
ashx
asp net
Asp.Net
Asp.Net Controls
Attribute
authentication
authorization
azure
BI
C#
C# 4.0
Code Plex
config
Context Menu
Cookie
cross browser
CSS
css3
Culture
database
DataReader
DataTable
debug
DEV
dynamic
EF
Encoding
Entity Framework
Extension Method
Facebook
Generic
Hacking
html
html5
HttpHandler
HttpModule
IDCC
iE
IE8
ie9
IIS
iis7
Internet Explorer
internet Explorer 8
internet Explorer 9
ITPRO
JavaScript
jQuery
js
JSON
Linq
meta
mvc
OFFICE
OFFTOPIC
Optional Parameters
PageMethods
PostBack
Power Point
reflection
Reflector
Reporting Services
Resource
SCC
Script Manger
SDP
Sela
Sela College Channel
silverlight
SQL Server
Static
stream
TECH
Teched_il
Telerik
Threading
UnitTest
User Control
UTF-8
Validators
video
Visual Studio
voice
VS2010
VSTO
WCF
Web
Web Service
Web Slice
WebApplication
WebMethod
WebService
Windows
Windows7
WinForms
XMLHTTP
קוד נכון
תפוז
ארכיון
February 2012 (1)
January 2012 (9)
December 2011 (7)
November 2011 (13)
October 2011 (9)
September 2011 (1)
August 2011 (4)
June 2011 (8)
May 2011 (13)
April 2011 (14)
March 2011 (12)
February 2011 (8)
January 2011 (18)
December 2010 (10)
November 2010 (16)
October 2010 (11)
September 2010 (9)
August 2010 (21)
July 2010 (12)
June 2010 (11)
May 2010 (21)
April 2010 (19)
March 2010 (14)
February 2010 (17)
January 2010 (13)
December 2009 (16)
November 2009 (10)
October 2009 (12)
September 2009 (22)
August 2009 (9)
July 2009 (14)
June 2009 (19)
May 2009 (17)
April 2009 (9)
March 2009 (11)
February 2009 (10)
January 2009 (16)
December 2008 (23)
November 2008 (11)
ניווט
Home
All Posts
RSS
Popular Tags
Browse by Tags
All Tags
»
Generic
(
RSS
)
C#
DEV
Extension Method
Linq
Static
WinForms
הפעלת Linq Queries על פקדים המכילים Collections ללא חשיפה של IEnumerable מתאים
25 November 11 11:25 AM
|
Shlomo
|
2 comment(s)
אחד מהיכולות החזקות של השפה שאנחנו משתמשים בהם רבות זהו היכולת להפעיל Linq to Objects על כל מי שמממש את: IEnumerable<T> ב - windows forms ישנם הרבה פקדים המכילים collections - כמו TabControl, TreeView ועוד. הבעייה עם כל הפקדים הללו שהם חושפים את IEnumerable הרגיל, (ללא T) מה שגורם לכך שאי אפשר להפעיל עליהם שאילתות לינק. כדי לתקן זאת ניתן להוסיף Extension Method מתאים לכל פקד ולהמיר את ה - IEnumerable לאחד שתומך ב - Generic, לדוגמא: internal static class Extension { internal static IEnumerable...
String extension - IsNullOrEmpty - ToEnum (Enum.Parse)
24 September 09 06:00 PM
|
Shlomo
|
3 comment(s)
אני משתמש די בקביעות עם שני extensions ל - string, וחשבתי לשתף אותם. הראשון: בדיקה האם מחרוזת אינה null או ריקה בדרך כלל מתבצעת בצורה הבאה string str; if (! string .IsNullOrEmpty(str)) { } היה הרבה יותר נחמד לולא היינו יכולים לשאול על ה - str - אבל מה לעשות שאולי ה - str הינו null (וזה שאלה מכשילה). השני: המרה ממחרוזת ל - enum מתבצעת בדרך כלל ככה: enum NyEnum { One, Two } NyEnum data = ( NyEnum ) Enum .Parse( typeof ( NyEnum ), "One" ); ולכן כתבתי את המחלקה הבאה: namespace System { public...
DataReader.GetValueOrDefault --> Extension for Extension
06 September 09 12:32 PM
|
Shlomo
| with
no comments
בהמשך לפוסט שהראה איך לקבל ערכי ברירת מחדל עבור עמודות שיכולות להיות NULL בבבסיס הנתונים. שלח לי חבר יקר ( בניהו) את ההצעה הבאה: public static T GetValueOrDefault<T>( this DbDataReader reader, int index) { if ( Convert .IsDBNull(reader[index])) { return default (T); } return (T)reader[index]; } public static T GetValueOrDefault<T>( this DbDataReader reader, string name) { if ( Convert .IsDBNull(reader[name])) { return default (T); } return (T)reader[name]; }