Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Desktop Developer

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Using Roboguice to inject your dependencies in an Android appVBCop or project Roslyn »
    comments

    Introduction

    I've been using nHibernate for quite a few years now and have been having plenty of success with it. But sometimes it's just to much. So today I had a little project I had to do and I decided I would take Massive from Rob Connery a spin.

    Install

    Well, there is no install. Massive is just a gigantic C# file that you would insert into your project if you were using C#. Of course you can't do that in VB.Net. For VB.Net you just create a new C# Class Library project and call it Massive, no need to be adventurous here. And then you just add a reference to that.

    You can now use nuget to add it to your project or just copy pates the Massive.cs file from github or use git of course to do it for you. Plenty of choices.

    Configuration

    Configuration of Massive is easy. It just needs a connectionstring.

    You set the connectionstring in your app.config of your main library and if you have a testproject don't forget to copy it there too.

    The app.config would look something like this.

    1. <?xml version="1.0"?>
    2. <configuration>
    3.     <connectionStrings>
    4.       <add name="msplog"
    5.            connectionString="yourconnectionstring"
    6.            providerName="System.Data.SqlClient"/>
    7.     </connectionStrings>
    8.     <startup>
    9.         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    10.     </startup>
    11. </configuration>

    I'm sure you know what bits to chance to make that work.

    The database

    I made one table in my database.

    Getting the data

    And finally we have arrived at the part we need.

    First we need to create a Class that inherits from DynamicModel for our Table. We can do this inline or make it a seperate class.

    This is the seperate class.

    1. Imports Massive
    2.  
    3. Namespace Services.MassiveModel
    4.  
    5.     Public Class MspLog
    6.         Inherits DynamicModel
    7.  
    8.         Public Sub New()
    9.             MyBase.new("MspLog", "tbl_MspLog", "Id")
    10.         End Sub
    11.  
    12.     End Class
    13. End Namespace

    I gave three parameters to the constructor. The first one is the name of the connectionstring I want it to use. If you don't specify that it will just pack the first one. The second is the name of the table and the third is the name of the primary key field I used.

    And then I can just query that.

    1. Dim tbl = New MassiveModel.MspLog
    2. Dim logs = tbl.All(orderBy:="DateLog DESC")

    AS you can see I returned all objects from the table and ordered them by DateLog in a descending order.

    Massive uses dynamic objects to return it's data so you will need to turn Option Strict Off.

    And then I can just show those objects to my users.

    1. For Each log In logs
    2.   Console.WriteLine(log.UserName)
    3.   Console.WriteLine(log.LogDate.ToString)
    4. Next

    And that is all there is to it.

    Conclusion

    Massive is also usable if you use winforms and VB.Net. And Massive is pretty simple to use.

    About the Author

    User bio imageChristiaan is a forensic technician who programs on the side, although my function description says that I do IT-things for 90% of the time . I'm an avid VB.NET fan and I use lots of the ALT.Net techniques, like unit-testing, nhibernate, logging, IoC, ...
    Social SitingsTwitterLinkedInHomePageLTD RSS Feed
    massive, vb.net
    Instapaper

    1 comment

    Comment from: SQLDenis [Member] Email
    SQLDenis Masssive is just a gigantic C# file.....

    Or better...

    Masssive is just a masssive C# file.....
    09/29/11 @ 04:07

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)