Serialize EF Tables to String NuGet Package

Takes an Entity Framework DBContext and Serialises the contents of all the tables specified in the List of strings to a string.



The utility Class can be used as follows:

string parameterString= $"Customers," + // Outputs all columns for all records in the Customer Table
$"Customers[]" + // same as above
$"Orders[OrderId;OrderQuantity]" + // outputs only the OrderId and
// OrderQuantity from all records in the Orders table
$"Payments[!PaymentId;Date]"; // Outputs columns EXCEPT PaymentId and Date from the Payments Table



SomeDbContext context = new SomeDbContext();
Formatter formatter = new Formatter();
String formattedOutputString = formatter.FormatEntities(context, parameterString);

The output string will have newline delimited lines as follows:

Customers
| CustomerId | Name | DateOfBirth |
| 1 | Jon Doe | 1982-03-12 |
| 2 | Eric Hand | 1966-04-15 |

Customers[]
| CustomerId | Name | DateOfBirth |
| 1 | Jon Doe | 1982-03-12 |
| 2 | Eric Hand | 1966-04-15 |

Orders[OrderId;OrderQuantity]
| OrderId | Quantity |
| 456 | 78 |
| 6578 | 65 |


Payments[!PaymentId;Date]
| PaymentAmount |
| 23.56 |
| 45.89 |

This last example assumes there were three columns ion the table two of which were excluded.

Note these are TABLE names not the Entity names as DbContext.Database.SqlQuery is used.




Got any Serialize EF Tables to String Question?





Info

Version: 2.0.5
Author(s): Jim Deane
Last Update: Sunday, June 5, 2016
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/jimdeane/SerializeEFTablesToString
NuGet Url: https://www.nuget.org/packages/SerializeEFTablesToString


Install
Install-Package SerializeEFTablesToString
dotnet add package SerializeEFTablesToString
paket add SerializeEFTablesToString
SerializeEFTablesToString Download (Unzip the "nupkg" after downloading)





STATS

must-have-score

.3

avg-downloads-per-day

1

days-since-last-release

3093