FileGDB.LinqPadDriver 0.1.1

dotnet add package FileGDB.LinqPadDriver --version 0.1.1
                    
NuGet\Install-Package FileGDB.LinqPadDriver -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FileGDB.LinqPadDriver" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FileGDB.LinqPadDriver" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="FileGDB.LinqPadDriver" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FileGDB.LinqPadDriver --version 0.1.1
                    
#r "nuget: FileGDB.LinqPadDriver, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FileGDB.LinqPadDriver@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FileGDB.LinqPadDriver&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=FileGDB.LinqPadDriver&version=0.1.1
                    
Install as a Cake Tool

FileGDB Driver for LINQPad

A driver for LINQPad that allows read-only access to the Esri File Geodatabase (also known as File GDB, FileGDB, or FGDB).

About

Esri File Geodatabases store spatial data as relational tables persisted in a bunch of files in a folder with the extension .gdb.

This package contains a driver for LINQPad that allows it to read File Geodatabases. The driver makes use of a small .NET library to read the File GDB; it does not use Esri's File Geodatabase API nor any other library.

How to use in LINQPad

  1. Install the driver
  2. Add a connection to a File Geodatabase
  3. Write queries (or any other .NET code)

Start LINQPad and click on Add connection. This opens the Choose Data Context dialog. At the bottom, click on View more drivers to open the LINQPad NuGet Manager. Click on Settings and make sure that the location of this NuGet is a package source; if not, add a new package source (see LINQPad documentation for details).

Once the driver is available to LINQPad, in the Choose Data Context dialog select "FileGDB Driver" and click Next. The File GDB Connection dialog appears, where you enter the path to the File GDB's .gdb folder.

A new data connection entry will appear and list all the tables in the File GDB. You can drag those table entries to a Query pane and use Intellisense to write LINQ queries against the table. For example:

Tables.MY_SHAPE_TABLE.Dump();
Tables.MY_SHAPE_TABLE.Select(row => row.SHAPE.ShapeBuffer).Dump();
Tables.MY_SHAPE_TABLE.Select(row => row.SHAPE.Bytes).Dump();
Tables.MY_SHAPE_TABLE.GetRow(5).Dump(); // get row by Object ID

As another example, here is how to retrieve properties about XY coordinate storage for each spatial table:

from entry in Catalog where entry.IsUserTable()
let table = entry.OpenTable()
where table.GeometryType != GeometryType.Null
let gdef = table.Fields.First(f => f.Type == FieldType.Geometry).GeometryDef
orderby entry.Name
select new {
  TableName = entry.Name, gdef.XOrigin, gdef.YOrigin,
  gdef.XYScale, // stored in the File GDB
  XYResolution = 1.0/gdef.XYScale, // reported by ArcGIS
  gdef.XYTolerance
}

Geometries can be formatted as WKT (well-knwon text format) with the ToWKT() method available on both the Shape and the ShapeBuffer class, and for convenience also directly on the GeometryBlob class (the optional integer argument is the number of decimal digits):

Tables.MY_SHAPE_TABLE.Select(r => r.SHAPE.ToWKT())

Query across all tables

The catalog exposed through the File GDB LINQPad driver is enumerable and each entry has an OpenTable() method. The returned table wrapper is itself enumerable, allowing you to write queries across all tables in a File GDB. For example, to find all multipart polyline features in any table:

from c in Catalog
where c.IsUserTable()
let table = c.OpenTable().Enumerable()
where table.GeometryType == GeometryType.Polyline
from row in table // SelectMany
where row.Shape.ShapeBuffer.NumParts > 1
select new {
  TableName = entry.Name, row.OID,
  Shape = Util.OnDemand(row.Shape?.ShapeType.ToString(), () => row.Shape),
  row.Shape.ShapeBuffer.NumParts,
  Operator = row.GetValue("OPERATOR")
}
  • The catalog entry's OpenTable() method returns a plain FileGDB.Core.Table object, which is not enumerable; the extension method Enumerable() returns a wrapper around the table that is enumerable.
  • The returned row objects have OID (type long), Shape (GeometryBlob, may be null), and Fields (list of the row's fields) properties.
  • They also have a GetValue(name) method that returns the value of the named field or null if the row has no such field.
  • A table does not know its name; to have the table name in the result rows, refer to the catalog entry's Name property (actually, the table wrapper returned by Enumerable() does have a Name property, but beware that the real table object of the underlying library does not).
  • LINQPad's Util.OnDemand() facility may be useful to allow “drill down” on the results.

As another example, count shapes, parts, and vertices per table; again we use Enumerable() to make the plain table returned by OpenTable() enumerable:

// Count parts and vertices per feature class:
from c in Catalog
where c.IsUserTable()
let n = c.Name
let t = c.OpenTable().Enumerable()
where t.GeometryType != GeometryType.Null
select new {
  Name = n,
  Shapes = t.Count(r => r.Shape is not null),
  Parts = t.Sum(r => r.Shape?.ShapeBuffer.NumParts ?? 0),
  Points = t.Sum(r => r.Shape?.ShapeBuffer.NumPoints ?? 0)
}

Geodatabase Items

On an abstract level, Esri software organizes data as items of various types. The item types form a hierarchy with Item at the root. For example, a FeatureClass is an AbstractTable, which is a Dataset, which is a Resource, which is an Item; and a CodedValueDomain is a Domain, which is also a Dataset.

  • type hierarchy is stored in the GDB_ItemTypes table
  • item details are defined by XML stored in the GDB_Items table
  • can use XElement.Parse() to access the XML content

A good view on Esri's understanding of what's in the Geodatabase can be obtained like this:

from i in Tables.GDB_Items
join t in Tables.GDB_ItemTypes on i.Type equals t.UUID
select new {
  Type = t.Name, i.Name, i.Path,
  Definition = i.Definition is null
    ? null
    : Util.OnDemand("Definition", () => XElement.Parse(i.Definition))
}

Limitations

  • this is experimental code and comes with no warranty
  • only a subset of the File Geodatabase is supported
  • Raster fields are not supported
  • MultiPatch geometries are not supported
  • only full table scans are supported
  • indices are not used and not accessible
  • no concurrency control (no locking)
  • strictly read-only (no updates)

References

This project would not have been possible without Even Rouault's detailed FGDB specification.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 107 1/24/2026
0.1.0-beta1 163 12/13/2025