Kaushal Gajjar

Kaushal Gajjar Kaushal Gajjar Kaushal

Niner since 2009

Comments

  • LINQ Language Deep Dive with Visual Studio 2008

    I am wondering what would be the correct way of giving a specific datatype to IQuariable of Anynomous using  "WITH". For example:

     

     Dim Contacts = From C In PracticeDB.Contacts _ 
    Select New With {.ID = C.ID, .Name = C.Name}

     

     Dim Query = New With {.ID = 1, .Name = "Kaushal"}

     

    In above both query it has "ID" and "Name" property of anonymous type.

     

    In above, How to specify "ID" property as Decimal? While selecting the statement from DataContext ID appears as Decimal because the type specified is "Numeric" in SQL Database.

     

    So far I found a way by parsing data type to integer in first query as following:

     

    Dim Contacts = From C In PracticeDB.Contacts _ 
    Select New With {.ID = Integer.Parse(C.ID), .Name = C.Name}

     

     Dim Query = New With {.ID = 1, .Name = "Kaushal"}

     

    I am wondering if there is any way to specify within WITH Statement.

     

     

  • LINQ Language Deep Dive with Visual Studio 2008

    Great overview! 

     

    Learning from this video is much easier then browsing msdn documents.