SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is VB.net equivalent

    Hi, what is vb.net equivalent for the following? Thanks

    C#
    Code:
    using (UtilityDataContext context = new UtilityDataContext())
                {
                    L2SSiteSetting result = context.L2SSiteSettings.SingleOrDefault(x => x.SettingId == id);
                    if (result != null)
                    {
                        setting = new SiteSetting {
                                          CreatedDate = result.CreatedDate == null ? new DateTime() : Convert.ToDateTime(result.CreatedDate),
                                          IsActive = result.IsActive != null && Convert.ToBoolean(result.IsActive),
                                          ModifiedDate = result.ModifiedDate == null ? new DateTime() : Convert.ToDateTime(result.ModifiedDate),
                                          SettingId = result.SettingId,
                                          SettingTypeId = result.SettingTypeId,
                                          SettingValue = result.SettingValue
                                      };
                    }
                }
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Location
    A city equidistant from two coasts of India.
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using context As New UtilityDataContext()
    Dim result As L2SSiteSetting = context.L2SSiteSettings.SingleOrDefault(Function(x) x.SettingId = id)
    If result IsNot Nothing Then
    setting = New SiteSetting() With { _
    Key .CreatedDate = If(result.CreatedDate Is Nothing, New DateTime(), Convert.ToDateTime(result.CreatedDate)), _
    Key .IsActive = result.IsActive IsNot Nothing AndAlso Convert.ToBoolean(result.IsActive), _
    Key .ModifiedDate = If(result.ModifiedDate Is Nothing, New DateTime(), Convert.ToDateTime(result.ModifiedDate)), _
    Key .SettingId = result.SettingId, _
    Key .SettingTypeId = result.SettingTypeId, _
    Key .SettingValue = result.SettingValue _
    }
    End If
    End Using

  3. #3
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •