I'm trying to insert a bunch of fogbugz cases into my own database but get a NotSupportedException: The member OutlineUri of type System.Uri cannot be used as a parameter value.
By creating args before passing it in I was able to ensure that I'm not referencing a null object (from this SO question). I can see that fogbugzCase.OutlineUri has a valid value when the exception is thrown.
Any ideas?
Here's the code (apologies about lots of indentation):
public void Foo(IEnumerable<FogbugzCase> cases)
{
using (SqlConnection conn = CreateConnection())
{
TruncateWorkingTable(conn, "Cases");
foreach (FogbugzCase fogbugzCase in cases)
{
int categoryId = fogbugzCase.Category.Id;
int? assigneeId = null;
if (fogbugzCase.PersonAssignedTo != null)
assigneeId = fogbugzCase.PersonAssignedTo.Id;
int? resolveeId = null;
if (fogbugzCase.PersonResolvedBy != null)
resolveeId = fogbugzCase.PersonResolvedBy.Id;
var args = new
{
BugId = fogbugzCase.BugId,
Title = fogbugzCase.Title,
ProjectId = fogbugzCase.Project.Id,
CategoryId = categoryId,
RootId = fogbugzCase.Root,
MilestoneId = fogbugzCase.Milestone.Id,
Priority = fogbugzCase.Priority,
StatusId = fogbugzCase.Status.Id,
EstimatedHours = fogbugzCase.EstimatedHours,
ElapsedHours = fogbugzCase.ElapsedHours,
PersonAssignedToId = assigneeId,
PersonResolvedById = resolveeId,
IsResolved = fogbugzCase.IsResolved,
IsOpen = fogbugzCase.IsOpen,
Opened = fogbugzCase.Opened,
Resolved = fogbugzCase.Resolved,
Uri = fogbugzCase.Uri,
OutlineUri = fogbugzCase.OutlineUri,
Spec = fogbugzCase.Spec,
ParentId = fogbugzCase.ParentId,
Backlog = fogbugzCase.Backlog
};
conn.Execute("INSERT INTO fogbugz.Cases(CaseId, Title, ProjectId, CategoryId, Root, MilestoneId, Priority, Status, " +
"EstimatedHours, ElapsedHours, AssignedTo, ResolvedBy, IsResolved, IsOpen, Opened, Resolved, Uri, ResolveUri, " +
"OutlineUri, SpecUri, ParentId, Backlog) " +
"VALUES(@BugId, @Title, @ProjectId, @CategoryId, @RootId, @MilestoneId, @Priority, @StatusId, @EstimatedHours, " +
"@ElapsedHours, @PersonAssignedToId, @PersonResolvedById, @IsResolved, @IsOpen, @Opened, @Resolved, @Uri, " +
"@ResolveUri, @OutlineUri, @Spec, @ParentId, @Backlog);",
args);
}
}
}