protected internal async Task <EntryData> GetEntryData(string entryName, EntryData parentLocator, bool isDirectory, SqlTransaction transaction) { EntryData result = new EntryData(); DataTable dt = await qs.FillDataTableInTransactionAsync(() => parentLocator == null ?FormatQuery(SqlStrings.GetEntryDataRoot) : FormatQuery(SqlStrings.GetEntryDataWithParent), transaction, p => { if (parentLocator != null) { p.AddWithValue("@ParentPathLocator", parentLocator.PathLocator); } p.AddWithValue("@EntryType", isDirectory ? 1 : 0); p.AddWithValue("@Name", entryName); }, CommandType.Text); if (dt.Rows.Count == 1) { result.LoadFromDataTable(dt); } else { result = null; } return(result); }
protected internal async Task <EntryData> GetEntryData(Guid streamId, bool getContent, SqlTransaction transaction) { EntryData result = new EntryData(); DataTable dt = await qs.FillDataTableInTransactionAsync(FormatQuery(getContent ? SqlStrings.GetEntryDataWithContentByStreamId : SqlStrings.GetEntryDataByStreamId), transaction, p => { p.AddWithValue("@StreamId", streamId); }, CommandType.Text); if (dt.Rows.Count != 0) { result.LoadFromDataTable(dt); } else { result = null; } return(result); }
private async Task <EntryData> CreateEntry(string entryName, EntryData parentLocator, bool isDirectory, byte[] content, SqlTransaction transaction) { EntryData result = new EntryData(); DataTable dt = await qs.FillDataTableInTransactionAsync(FormatQuery(SqlStrings.CreateEntry), transaction, p => { var varbinary = p.Add("FileStream", SqlDbType.VarBinary); varbinary.Value = content ?? (object)DBNull.Value; p.AddWithValue("@EntryName", entryName); p.AddWithValue("@EntryType", isDirectory ? 1 : 0); p.AddWithValue("@ParentLocator", parentLocator == null ? "/" : parentLocator.PathLocator); }, CommandType.Text); if (dt.Rows.Count != 0) { result.LoadFromDataTable(dt); } result.Content = content; return(result); }