protected virtual IQueryable <T> PrepareQuery(IReadOnlyUnitOfWork context) { UnitOfWork = context; CheckContextAndQuery(ContextQuery); var query = ExtendQuery(); return(AppendExpressions(query)); }
protected IQueryable <TProjection> PrepareQuery(IReadOnlyUnitOfWork context) { UnitOfWork = context; CheckContextAndQuery(Selector); var query = ExtendQuery(); return(AppendExpressions(query)); }
public T Execute(IReadOnlyUnitOfWork context) { var efContext = context as DbContext; using (var conn = new SqlConnection(efContext.Database.Connection.ConnectionString)) { return(ContextQuery.Invoke(conn)); } }
public UserAuthorizationService( IReadOnlyUnitOfWork readOnlyUnitOfWork, IUnitOfWork unitOfWork, IPasswordCryptoService passwordCryptoService ) { _readOnlyUnitOfWork = readOnlyUnitOfWork; _passwordCryptoService = passwordCryptoService; _unitOfWork = unitOfWork; }
public IEnumerable <T> Execute(IReadOnlyUnitOfWork context) { var efContext = context as DbContext; if (efContext == null) { throw new InvalidOperationException("You cannot execute EF Sql Queries against a non-EF context"); } using (var conn = new SqlConnection(efContext.Database.Connection.ConnectionString)) { return(ContextQuery.Invoke(conn)); } }
public virtual string OutputQuery(IReadOnlyUnitOfWork context) { IQueryable <TProjection> query = PrepareQuery(context); return(query.ToString()); }
/// <summary> /// This executes the expression in ContextQuery on the context that is passed in, resulting in a /// <see cref="IQueryable{T}" /> that is returned as an <see cref="IEnumerable{T}" /> /// </summary> /// <param name="context">the data context that the query should be executed against</param> /// <returns> /// <see cref="IEnumerable{T}" /> /// </returns> public virtual IEnumerable <TProjection> Execute(IReadOnlyUnitOfWork context) { IQueryable <TProjection> task = PrepareQuery(context); return(task); }
/// <summary> /// Executes the expression against the passed in context /// </summary> /// <param name="context">The data context that the scalar query is executed against</param> /// <returns>The instance of <typeparamref name="T" /> that the query materialized if any</returns> public T Execute(IReadOnlyUnitOfWork context) { UnitOfWork = context; CheckContextAndQuery(ContextQuery); return(ContextQuery((UnitOfWork)context)); }
public string OutputSQLStatement(IReadOnlyUnitOfWork context) { return(OutputQuery(context)); }
public string OutputQuery(IReadOnlyUnitOfWork context) { return(SqlStatement); }
/// <summary> /// This executes the expression against the passed in context to generate the SQL statement, but doesn't execute the /// IQueryable<typeparamref name="T" /> against the data context /// </summary> /// <param name="context">The data context that the query is evaluated and the SQL is generated against</param> /// <returns></returns> public string OutputQuery(IReadOnlyUnitOfWork context) { return(ExtendQuery().ToString()); }
/// <summary> /// This executes the expression in ContextQuery on the context that is passed in, resulting in a /// <see cref="IQueryable{T}" /> that is returned as an <see cref="IEnumerable{T}" /> /// </summary> /// <param name="context">the data context that the query should be executed against</param> /// <returns> /// <see cref="IEnumerable{T}" /> /// </returns> public virtual TProjection Execute(IReadOnlyUnitOfWork context) { TProjection task = PrepareQuery(context); return(task); }
public string OutputQuery(IReadOnlyUnitOfWork context) { var query = PrepareQuery(context); return(query.ToString()); }
/// <summary> /// This executes the expression in ContextQuery on the context that is passed in, resulting in a /// <see cref="IQueryable{T}" /> that is returned as an <see cref="IEnumerable{T}" /> /// </summary> /// <param name="context">the data context that the query should be executed against</param> /// <returns> /// <see cref="IEnumerable{T}" /> /// </returns> public virtual IEnumerable <T> Execute(IReadOnlyUnitOfWork context) { var task = PrepareQuery(context); return(task); }
private static async Task <int?> GetAttachmentsCodeFromObjectAsync(IAttachmentsService.ObjectType objectType, string objectKey, IReadOnlyUnitOfWork uow) { // Invoice, Order, Quotation, CreditNote, DeliveryNote, DownPaymentRequest switch (objectType) { case IAttachmentsService.ObjectType.BusinessPartner: var bp = await uow.BusinessPartners.FindByIdAsync(objectKey) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(bp.AttachmentsCode); case IAttachmentsService.ObjectType.Order: var order = await uow.Orders.FindByIdAsync(Convert.ToInt32(objectKey)) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(order.AttachmentsCode); case IAttachmentsService.ObjectType.Quotation: var quo = await uow.Quotations.FindByIdAsync(Convert.ToInt32(objectKey)) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(quo.AttachmentsCode); case IAttachmentsService.ObjectType.Invoice: var inv = await uow.Invoices.FindByIdAsync(Convert.ToInt32(objectKey)) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(inv.AttachmentsCode); case IAttachmentsService.ObjectType.CreditNote: var cn = await uow.CreditNotes.FindByIdAsync(Convert.ToInt32(objectKey)) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(cn.AttachmentsCode); case IAttachmentsService.ObjectType.DeliveryNote: var dn = await uow.DeliveryNotes.FindByIdAsync(Convert.ToInt32(objectKey)) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(dn.AttachmentsCode); case IAttachmentsService.ObjectType.DownPaymentRequest: var dpr = await uow.DownPaymentRequests.FindByIdAsync(Convert.ToInt32(objectKey)) ?? throw new NotFoundException($"{objectType} key={objectKey} not found"); return(dpr.AttachmentsCode); default: throw new IllegalArgumentException($"Object type: {objectType} not supported"); } }