Wednesday, October 11, 2017

LINQ using two tables on Managed Dbf


A demonstration of querying two Managed Dbf tables using LINQ to find all sales record of a particular customer and display it's Sales Invoice No. and  Amount.




Managed Dbf can do it in the good old fashion but effective way, an xBase style of gathering information without using a querying language.





Managed Dbf Methods and Properties are almost identical to Visual FoxPro Commands.


Thursday, October 5, 2017

LINQ saved my day!


LINQ saved my day by writing my own OLEDB and OBDC driver for Managed Dbf, I'm in the process of learning, researching and studying how to build my own OLEDB like VFPOLEDB to support querying language until I read  Why LINQ beats SQL .

Now, I don't have to go through the lengthy process of creating my own Data Provider or to load any OBDC Driver or using any ADO/NET data connector for Managed Dbf  just to have a querying language to gather information, LINQ now can be use to query data in Managed Dbf  but it's still in early stage. I Quoted from LINQPad creator "LINQ is in most cases a significantly more productive querying language than SQL."

I wanted Managed Dbf to be free of any third party library or driver with only minimum set of .Net Assemblies, by using LINQ which is a major part .NET Framework since .NET 3.5 uses an SQL-like syntax to make a query expressions.

Managed Dbf using LINQ in action  :











XBase / Clipper / Visual FoxPro Equivalent Commands  :





Friday, June 16, 2017

Lambda Expression for Deletion



Lambda expression, it's an anonymous function it can use to create delegates or expression tree, by using lambda conditions, we can write local functions that can be passed as parameters. Let's see it in action for deleting a records using Lambda expression for Where and While condition in Managed Dbf and it's equivalent xBase/Clipper/Vfp code.

TASK
Delete all customers from USA country and state of New York or California.


.

Solution 1 :  ( Slowest )

This is the slowest solution, iterating to all records and check if we meet the condition criteria before
marking the record for deletion.




Equivalent xBase/Clipper/VFP commands :




.


Solution 2 :  ( Slow )

This is slow but not the slowest solution, any method using *All in Managed Dbf are using disk caching for reading all records and this solution is only using single line of code and lambda expression condition for deleting a record.








Equivalent xBase/Clipper/Vfp commands :








.




Solution 3 :  ( Fast )

This is a fast solution because it uses index file to searching country and continue reading WHILE the country still match the search and test for state conditions before marking the record for deletion.
















Equivalent xBase/Clipper/Vfp commands :





.


Solution 4 :  ( Fastest )

This is a fastest solution because it uses index file for searching country+state and continue reading WHILE the search condition is true before marking the record for deletion.




Equivalent xBase/Clipper/Vfp commands :





Saturday, April 29, 2017

What's wrong extending the life of Dbf file format : - D


I already know what's your thinking... You may say maybe I'm just reinventing the wheel. Why not design my own programming languages and write my own compilers for them? Or even better create my own operating system from scratch? 😄 because there are fricking hundreds if not thousands of available database projects out there in the wild which are ready to use and battle tested.

Whenever you can’t find some information you are looking for a certain applications, or a good software library but lacking some option and features you need, why not create your own? If you have the luxury of time and you believe you can do it, why bother using a third-party software or the work of others.

Alright, aside from the pleasure I get writing codes, fulfilling my enthusiasm for extending the life of DBF file format and staying close to the xBase commands in terms of data manipulation; has given me a great deal of enjoyment particularly in the learning process, these already are greenlight indications that I should keep continuing what I’m doing.

Imagine without any heavy weight database engine or anything to be installed on ones computer but yet you can create a fast, multiuser and easy record manipulation even in billions of records.



C# Using Managed Dbf :


// Create table free instance
var _CUSTOMER = new MDb.Table();

// Open Dbf file in shared mode and read-only
_CUSTOMER.File.Open( @"\\MyServer\Fileman\Customer.Dbf",
                                       TableShare.Shared, TableAccess.ReadOnly, TableMaxSize.MaxOf16G );

// Set sort order by country + state

_CUSTOMER.Indexer.SetOrderTo("COUNTRYSTATE");




Visual FoxPro/xBase Equivalent commands :

SELECT 0

USE \\MyServer\Fileman\CUSTOMER.Dbf  SHARED NOUPDATE

SET ORDER TO COUNRYSTATE




What's has been extended so far  :

* Managed Dbf can open different types of DBF file format.
     - Can open Dbf file format even with unsupported field type.

* Extended the 2GIG limitation on table size.
     - The Dbf table is still compatible if the size less than 2GIG

* Extended the field name length to 32 default value is 10
     - The Dbf table is still compatible, Managed Dbf will only created
       an extension file to store some extended information.

* Not relying on CDX Index file, Managed Dbf uses ZDX for Index file
    - Since Managed is not using and abandoning VFP Runtime, VFPOLEBD, ADO/NET, ODBC
      I created my own custom index file and called it ZDX file : - D


Friday, December 16, 2016

Xbase language is making a comeback!


xBase is a term for programming language derived from dBase which was release in 1980 from Ashton-Tate under CP/M operating system. Hat's off to the people whose responsible for making the Dbf file format and Nantacket for making the compiler to produced a stand alone royalty free executable file.

Some of well known xBase dialects are dBase, Clipper, FoxBase, FoxPro, Visual FoxPro, Paradox, Visual Object, Recital, RBase, Vulcan, FlagShip and there's a lot more out in the wild.

I'll say Goodbye to Visual FoxPro sooner or later which is a discontinued product by Microsoft and I'll will say Hello to the following active xBase dialect  listed below:

Xbase++      http://www.alaska-software.com/
dBase+ 11   http://www.dbase.com/
X#               https://www.xsharp.info/
xHarbour     http://www.xharbour.org/
  /3rdParty      http://www.fivetechsoft.com/english/index.php
Apollo http://www.apollodb.com/default.asp


























































Award-winning, embedded database engine for developing Windows applications that manage CA-Clipper and FoxPro 2.6 DBF database files locally or on a shared LAN environment. Includes ADO.NET Data Provider for .NET and native VCL components for Delphi & C++Builder.

Optional database server (Windows only) allows Apollo Embedded applications to connect to CA-Clipper, FoxPro 2.6 and Apollo data files over TCP/IP. Ideal for building client/server applications or for connecting to data files stored on remote servers. Requires Apollo Embedded 9.0 (Sold separately)






Monday, October 17, 2016

PROLEGOMENON



PROLEGOMENON

Managed Dbf is a personal project of mine, on which the master plan is to create a lightweight RDBMS library for .Net.  that should be a fast multi-user relational and thread safe database file management system, easy to use and  easy to understand, using some of the familiar commands that can be found on Visual FoxPro, Clipper and other xBase compatible RDBMS. with an optional secured Client-Server base model.


OPEN SOURCE

I'm planning to open the source code of Managed Dbf once the project is completed and has reach the beta state or when I already using it for production use.


ALTERNATIVE TO VISUAL FOXPRO

Any suitable alternative for Visual FoxPro? Well, I can't find one! I’ve been professionally developing business applications for more than 10 years mostly from small to medium-size enterprises, most of my applications are written in Visual FoxPro since Version 3.0 up until to the last version 9.0 SP2. So yeah, VFP is my bread and butter because it’s the best tool for getting things done specifically in developing enterprise desktop line of business applications.

To most VFP developers the following site and announcement from VFP team is not new "MS is not planning on releasing a VFP 10" it was really a sad news to all FoxPro fanatics like me. Nonetheless, rather than whining, I better start looking for an alternative tools for my future projects. I’m still looking up until 2020 till I stop developing application in VFP and as long as my clients couldn’t care less whatever development tools I use, as long as I continue to meet all of their requirements on time( VFP is a RAD tools, you know : - D  I’m still going to use it.

Don’t get me wrong, I love keeping up with the new and latest technology and most of the time I usually hop on to the bandwagon on the latest technology and try to come up with something useful that I can use for my projects and It’s no brainer to just stick to one development tools, environment and programming languages particularly if you are a business software solution provider.



THE TECHNOLOGY IS HERE


Yes, yes the technology is there. Only too many to choose from and most of the time it’s far too complicated for the end-users to get started and when you get the feeling that it’s a bit bloated, heavy weight, too much use of resources and experienced the install and uninstall hell the frustration of finding an alternative to VFP is getting worse. True, there are lots of available tools out there but it’s too fragmented, NuGets here NuGets there, you need lots of add-on and other third party software just to make simple line of business application out of the box.

Still, I can’t find a robust data centric development tools like what Visual FoxPro can offer, sure there’s Microsoft Access and LightSwitch :D but I rather create a full blown business application in Visual Studio and .Net framework. VFP is dead, XNA is dead, Silverlight is dead, MS Access and LightSwitch may die, but .Net Framework probably last and evolved; not to mention that it can be ported to Mono using Xamarin with just a little effort.


BEST OF BOTH WORLD


dBASE was different from programs like BASIC, C, FORTRAN, and COBOL in that a lot of the dirty work had already been done. The data manipulation is done by dBASE instead of by the user, so the user can concentrate on what he is doing, rather than having to mess with the dirty details of opening, reading, and closing files, and managing space allocation”. -- Wayne Ratliff 

As one of the great grandparents of dBase noted that ( dBase, Clipper, xBASE and Visual FoxPro ) is a different beast in terms of data manipulation like in most general programming languages and C# is no exception to that. So, why not use the best of both worlds by using Visual Studio as the development tools and .Net Framework as the language C#/VB and create a library that can bring the ease of use in data manipulation on DBF table without using VFP itself or it's runtime or any other 3rd party software library and Database drivers like OBDC, OLEDB or ADONET by using .Net LINQ automagically you have an SQL-Like syntax on gathering information. It doesn't even need a heavy weight Entity Framework either to work with Data Model using Scatter and Gather approach to record a row object  in just a single line of code.


DISCLAIMER


Since I’m still heavily working on this technology there will be a stiff learning curve and heavy research on this project, and I don’t guarantee that everything I will mentioned and posted down from here is technically accurate and correct, what I have here is based on my own research, interpretation and understanding to the database file management subject and should not be consider as facts or best approach, so better take my posts with a grain of salt and BTW English is not my first language.


NOTE


Blog contents related to Managed Dbf development may be modified from time to time to comply with library's latest revision and for future referencing.