Salvo Davide Rapisarda

Italian developer thinks.
Linq2Sql: How to loop over context tables ?

I use linq2sql in my project not using direct table mapping but using sql views as link. Sometimes (all depend by other collegues) there is a reason for modify/add a table field in db structure. Ok, I think it's normally but if the table is included in a view then my context goes "BOOM!!!".

I have a context with 33 entities and every time i don't want to check one by one.

Problem: How to check if every entity doesn't have mapping problem?

Solution: Loop over every entities and call Any() method for each entity.

Description: If, for each entity in context, call Any() method then I can found where there is a mapping problem,

Code:

Private Function DoTest()
        Dim properties() As PropertyInfo
        
        properties = GetType(MyDataClassesDataContext).GetProperties()
        For Each p In properties
            If p.PropertyType.IsGenericType Then
                Dim attribs() As Object
                attribs = p.PropertyType.GetGenericArguments()(0).GetCustomAttributes(GetType(TableAttribute), False)
                If (attribs.Length > 0) Then
                    
                    If p.Name IsNot Nothing Then                                                                                         
                        resultList.Add(getItem( db.GetTable(DirectCast(db.[GetType]().GetProperty(p.Name).GetValue(db, Nothing), ITable).ElementType)))                       
                    End If
                    
                End If
            End If
        Next

End Function
Private Function getItem(ByVal o As ObjectAs ResultItem
        Dim result As ResultItem
        Dim errmsg As String
        errmsg = ""
        If TryInvokeEntity(o, errmsg) Then
            result = New ResultItem With {.ViewName = o.ToString(), .Status = "OK", .ErrorMessage = ""}
        Else
            result = New ResultItem With {.ViewName = o.ToString(), .Status = "KO", .ErrorMessage = errmsg}
        End If
        
        Return result
End Function
 
 
Private Function TryInvokeEntity(ByVal source As IQueryableByRef errmsg As StringAs Boolean
        Dim first As MethodCallExpression
        
        first = Expression.Call(GetType(Enumerable), _
                               "Any", _
                               New Type() {source.ElementType}, _
                               New Expression() {source.Expression})
        Try
            source.Provider.Execute(first)
            Return True
        Catch ex As Exception
            errmsg = ex.Message
            Return False
        End Try
        
        
End Function
 
 
70-480...got it!

Yesterday I was received a mail from Microsoft with a subject like "Congratulations on Your Microsoft Certification!"

Microsoft certification? what?!? In first time i really think that was spam and put it on trash.

But I was remember that in June i have done 70-480 Programming in HTML5 with JavaScript and CSS3 beta exam!

I can't believe!!! ^_^  Prometric.com confirm the i have pass the exam!!

 Yeah!

 

Posted: Sep 20 2012, 09:07 AM by Blackat.NET | with no comments
Filed under: , ,
DeployManager - A helpful digital certificate manager tool

DeployManager is a tool written by Raffaele Rialdi for deals with digital certificates.
My first impression about this tool is....Wow! I searched a tool like this for years without finding it! ^_^


If you want to try this tool you can download at this link

 

A good list of programmer tools

Every day I spend 30 minutes of my time to find new and interesting blogs. Today I have found a blog of Andre Ignat, a MVP of Romania (link).
In this blog there is a very nice page with a list of programmer tools.

I think it's a good "start point" for prepare a developer machine. ;)

 

C# and VB.NET language specification

Hi,

If you search in your vs installation dir under subfolder Microsoft Visual Studio 10.0\VB\Specifications and Microsoft Visual Studio 10.0\VC#\Specifications you can found documents about language specificaiton.

If you have 5 minutes to spend i think it's a good reading. ;-)

Salvo.

Certificate Store Migration

Where system certificate are located?

See this http://msdn.microsoft.com/en-us/library/windows/desktop/bb204781%28v=VS.85%29.aspx


Use certificates in WCF client

This is a good tutorial for configure WCF and X.509 certificate authetication.

 

http://www.codeproject.com/KB/WCF/9StepsWCF.aspx

 

I have a problem when I have specified X509FindType attribute in clientCertificate element. The problem is that i have write the attribute with first char (X) in uppercase. The correct syntax x in lower case!!!

Posted: Nov 18 2011, 06:30 PM by Blackat.NET | with no comments
Filed under:
SSMS Tools Pack

SSMS Tools Pack is an add-in for Microsoft SQL Server Management Studio (SSMS) 2005, 2008, 2008 R2, Denali CTP3 and their respective Express versions.
It contains a few upgrades to the SSMS IDE that I thought were missing.

 

For other info see http://www.ssmstoolspack.com/

 

 

Posted: Nov 07 2011, 06:33 PM by Blackat.NET | with no comments
Filed under:
Programming like making music

This morning, while I was driving to work, a think was made in my mind. In this days I'm learning how to play classic guitar, and I was think: what kind of difference there are between make music and make software?. I think that there is no difference. If you compare music with programming, there are 7 notes (DO, RE, MI, FA, SOL, LA,SI) for making music while in computer programming we are a set of principal statements (IF,LOOPS,TYPES,ASSIGNMENTS)  for making software. If you make music you need a musical instrument (guitar, violin,ecc..) and a sequence of notes (for a predeterminated execution time). If you make software you need a good programming language as instrument (C#,VB.NET,JavaScript,ecc..) and make a sequence (in certain case a very long sequence :-)  ) of statements.

If you think to create software in this way (like music) I think that you can create a very good software in any kind of enviroment and language.

Productivity Power Tools for VS 2010 - Update Available

 A new release of Productivity Power Tools is now available from Visual Studio Gallery. Here is the link to the page. I like so much this tools for Visual Studio!

 

More Posts Next page »