I’m hoping there will be a crazy linq answer to this, it feels like there should be
Current code:
MapHierarchy().Case<Folder>(f => new { FolderId = f.Id,
f.Name,
Type = 1 })
.Case<RootFolder>(f => new { f.RootName,
Type = 2 })
.ToTable("Folder");
Another method:
void AddAnotherFolder(something)
{
something.Case<RootFolder>(f => new { f.RootName, Type = 2 })
}
What I would like to be able to do is pass that method into the MapHierarchy string – is that possible?
Something like…
MapHierarchy().Case<Folder>(f => new { FolderId = f.Id,
f.Name,
Type = 1 })
.Case<RootFolder>(f => new { f.RootName,
Type = 2 })
.AddAnotherFolder(this)
.ToTable("Folder");
It feels like a linq question, would be VERY cool if it could
Look at the method signature for
Case<T>. You should be able to create a similar extension method in a static class with where clauses for your particular types. It might look something like this:And to call it you’ll just do
.AddAnotherFolder()without the (this).[NOT TESTED, BUT IT WILL BE SOMETHING LIKE THAT]