This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_db.RetryOnTransientErrorAsync(cancel | |
, db => db.WithSql( | |
q=>q.From<AssetsWithContextViewRow>() | |
.Where(d=>d.ProjectId==input.ProjectId && d.Name.Contains(input.Word)) | |
.Limit(30) | |
.SelectAll(useAsterisk:true) | |
.MapTo<AssetInfoWithContext>() | |
) | |
.GetRowsAsync()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//config | |
ServiceBus.ConfigureWith(new AutofacBusConfigurator(_boot.Container)) | |
.ForMonolith(bus => | |
{ | |
bus.PersistAuditsWith(new InMemoryAuditStorage()) | |
.WithoutErrorsQueues() | |
.ConfigureSagas(s=>s.WithoutSagas()) | |
; | |
bus.WithSqlServerStorages(_boot.DbConnection, | |
d => d.EnableProcessorStorage().EnableReserveIdStorage()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//selecting related assets from a view then processing each row | |
//into a RelatedItem which gets added to a result | |
//generated sql is | |
//select [Id],[Type],[Name],[ContextId] from [AssetUsagesView] | |
//where ((([AssetId] = @0) and ([ProjectId] = @1)) and [Category] in (@3,@4)) | |
using (var db = await _db.CreateAsync(cancel)) | |
{ | |
await db.QueryAndProcessAsync( | |
q => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a POCO , used as a source to create a table. In SqlFu 3, POCOs are **sources** or **destinations** of data, | |
// there is no object to table mapping like in an ORM | |
public class AssetsRow | |
{ | |
public Guid Id { get; set; } | |
public Guid ProjectId { get; set; } | |
public Guid? ContextId { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReadModelUpdater: | |
ISubscribeTo<CommandCreated>,ISubscribeTo<CommandDeleted>,ISubscribeTo<CommandRenamed> | |
,IExecute<UpdateCommandDetails>,IExecute<UpdateCommandBehaviour>,IExecute<UpdateCommandConstraints>,IExecute<UpdateCommandModel> | |
,IExecute<AddTrigger>,IExecute<RemoveTrigger> | |
,IExecute<AddQueryToCommand>,IExecute<RemoveQueryFromCommand> | |
,ISubscribeTo<CommandOutcomeAdded>,ISubscribeTo<CommandOutcomeDeleted>,ISubscribeTo<CommandOutcomeRenamed> | |
,IExecute<AddEventToOutcome>,IExecute<RemoveEventFromOutcome> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SqlFuManager.Configure(c => | |
{ | |
c.AddProfile(SqlServer2012Provider.Instance, Setup.Connex); | |
}); | |
_getDb = SqlFuManager.GetDbFactory(); | |
_getDb.Do(db => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Task<OutputValue<Guid>> HandleAsync(GetOrganizationId input, CancellationToken cancel) | |
{ | |
return GetDataAsync("org" + input.Name, async () => | |
{ | |
return await _db.DoAsync(async d => | |
{ | |
OutputValue<Guid> result = null; | |
var res = await d.GetValueAsync<Guid?>("select Id from Orgs where Organization=@0", input.Name); | |
if (res.HasValue) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyConventions:AspNetMvcConventionsModule | |
{ | |
public void override Configure(AspNetMvcConventions convetions) | |
{ | |
conventions.Always | |
.ControllersLookLike(type=> type.Name.EndsWith("Endpoint")) | |
.ActionsLookLike(methodInfo=> methodInfo.IsPublic); | |
//or | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Post(AddPageModel model) | |
{ | |
if (model.IsEmpty) | |
{ | |
goto redirect; | |
} | |
var createPageData = new CreatePageData(model,this.GetCurrentTenantId()); | |
if (model.Cmd == AddDocumentModel.CmdDraft) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//view engine convention which select a different template for the same type, depending on model value | |
// when Format is html we want DocumentContent.html.chstml | |
// when Format is markdown we want DocumentContent.markdown.chstml | |
//etc | |
public class DocumentContentTemplates : IFindViewConvention | |
{ | |
public bool Match(ControllerContext context, string viewName) | |
{ | |
return viewName.Contains("DocumentContent"); | |
} |
NewerOlder