Base solution for your next web application

Activities of "klawsuc"

Question

The datatable in Prime NG was deprecated. Is there are reason why the ASP.NET ZERO is still using it in v6? I want to make sure there isn't something extra happening in the datatables befor I switch them to turbotable. I will be using turbotable for all my custom pages and want to keep a consistent look.

Not sure if the subject line reflects what I want. I have a repository for a Company which has a relationship to CompanyAddresses which in turn has a relationship to Addresses. I have the following code to get the Company and related data. However I would like to get the actual Addresses referenced in the CompanyAddresses table in the same query if possible.

var company = await _companyRepository
                    .GetAllIncluding(
                        c => c.Patients,
                        c => c.CompanyAddresses,
                        c => c.CompanyEmails,
                        c => c.CompanyPhones
                    )
                    .FirstOrDefaultAsync(o => o.Id == input.Id);

Company class has the following:

public virtual ICollection<Patient> Patients { get; set; }
public virtual ICollection<CompanyAddress> CompanyAddresses { get; set; }
public virtual ICollection<CompanyEmail> CompanyEmails { get; set; }
public virtual ICollection<CompanyPhone> CompanyPhones { get; set; }

I have the following classes/tables:

Company : FullAuditedEntity<int>, IPassivable, IExtendableObject
Address : FullAuditedEntity<int>, IPassivable
CompanyAddress

The CompanyAddress class has the companyId, addressId, and an address type..it does not have an entity id like the other classes. I want to be able to add an address and if successful, add an entry into companyAddress. Then commit the changes so that these entries are only saved if they both succeed.

First of all what is the best way to add a record to the non-entity table (CompanyAddress). In the CompanyAppService i added

private readonly IDbContextProvider<DbContext> _contextProvider;

Then in the AddAddress method I have

CompanyAddress ca = new CompanyAddress();
ca.AddressId = addy.Id;
ca.CompanyId = input.CompanyId;
ca.AddressTypeId = input.AddressTypeId;
DbContext dbc = _contextProvider.GetDbContext();
dbc.Add(ca);

Next question, I have an AddressAppService with an insert method. So in the CompanyAppService.AddAddress should I be creating an instance of the AddressAppService and using the insert method to create the address? Or should I just create the record directly like I'm doing with CompanyAddress?

Basically what I am looking to have:

//Create an Address record and get the generated ID
//Insert a record into CompanyAddress
//on success of both, commit the changes to the db
//on failure, cancel saving the address

Should I be using UoW for this or just do an insert of the address and if it succeeds, attempt to add a record to CompanyAddress and if that fails, remove the address?

I get the following error when starting my app on the server (Core 1.1 + Angular 4 - aspnetzero 4.1.1)

Application startup exception: System.Data.SqlClient.SqlException: Invalid object name 'AbpEditions'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnection)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer)
   at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func`2 operation, Func`2 verifySucceeded, TState state)
   at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.&lt;_ShapedQuery&gt;d__3`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at lambda_method(Closure , QueryContext )
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.&lt;&gt;c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at SquireLab.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() in 
...
ClientConnectionId:f35937a1-f012-41ce-b256-9d370b18d9e2
Error Number:208,State:1,Class:16
Hosting environment: Production
Content root path: C:\...
Now listening on: http://localhost:5291
Application started. Press Ctrl+C to shut down.

Using build 4.4.0 (Core + Angular), Visual Studio 2017, Typescript 2.5 (installed VS extension). I get the following error when I try to build the *.Web.Host project.

npm - v5.4.1 node - v6.11.3 tsc - v0.8.3.1

Question

I want to return a Dto that has data from nested related tables (not sure how else to word this). Here is a sample of what the structure would look like:

  • Household (only one)
  • People (one or more that belong to a house)
  • Pets (one or more that belong to a person...no relation to house)
  • Toys (one ore more that belong to a pet...no relation to house or person)

I would like to return a dto with all the people, pets, and toys at a specific house. Household table has:

public virtual ICollection<Person> People { get; set; }

Person table has:

public virtual ICollection<Pet> Pets { get; set; }

Pet table has:

public virtual ICollection<Toy> Toys { get; set; }

GetHouseDataDto (the dto I am trying to return) has:

public HouseViewDto House { get; set; }
public ICollection<PersonViewDto> People { get; set; }
public ICollection<PetViewDto> Pets { get; set; }
public ICollection<ToyViewDto> Toys { get; set; }

I have the following query:

var house = await _houseRepository
    .GetAll()
    .Include(c => c.People)
    .FirstOrDefaultAsync(f => f.Id == input.Id.Value);
output.House = ObjectMapper.Map<HouseViewDto>(house);
output.People = ObjectMapper.Map< List<PersonViewDto>>(house.People);

How do I also include pets and toys?

Thanks.

Showing 1 to 6 of 6 entries