Simply.Property
0.1.2
.NET Core 3.0
This package targets .NET Core 3.0. The package is compatible with this framework or higher.
.NET Framework 4.8
This package targets .NET Framework 4.8. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Simply.Property --version 0.1.2
NuGet\Install-Package Simply.Property -Version 0.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Simply.Property" Version="0.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Simply.Property --version 0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Simply.Property, 0.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Simply.Property as a Cake Addin #addin nuget:?package=Simply.Property&version=0.1.2 // Install Simply.Property as a Cake Tool #tool nuget:?package=Simply.Property&version=0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NuGet installation
Install the Simply.Property NuGet package:
PM> Install-Package Simply.Property
The Install-Package Simply.Property
is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.
Step #1. Implement interface IRepository, Repository and RepositoryFactory
public class Repository<T> : IRepository where T : DbContext
{
protected T ctx;
public Repository(T context) { ctx = context; ctx.Database.SetCommandTimeout(300); }
public Task<int> ExecuteSqlAsync(string query) => ctx.Database.ExecuteSqlCommandAsync(query);
public Task<int> ExecuteSqlWithJsonAsync(string query, string json) => ctx.Database.ExecuteSqlCommandAsync(query, new SqlParameter("@json", json));
public Task<int> ExecuteSqlAsync(RepositorySqlQuery query) => (query.Json != null) ? ExecuteSqlWithJsonAsync(query.Query, query.Json) : ExecuteSqlAsync(query.Query);
public async Task ExecuteSqlWithTransactionAsync(IEnumerable<RepositorySqlQuery> queries)
{
using (var transaction = await ctx.Database.BeginTransactionAsync().ConfigureAwait(false))
{
try
{
foreach (var query in queries)
await ExecuteSqlAsync(query).ConfigureAwait(false);
transaction.Commit();
}
catch(SqlException)
{
transaction.Rollback();
}
}
}
public Task<List<TEntity>> GetAsync<TEntity>() where TEntity : class => ctx.Set<TEntity>().AsNoTracking().ToListAsync();
public Task<int> AddAsync<TEntity>(TEntity entity) where TEntity : class
{
ctx.Add(entity);
return SaveAsync();
}
public Task<int> AddManyAsync<TEntity>(IEnumerable<TEntity> entities) where TEntity : class
{
foreach (var entity in entities)
ctx.Add(entity);
return SaveAsync();
}
public Task<int> SaveAsync() => ctx.SaveChangesAsync();
public void Dispose() => ctx.Dispose();
}
public class SampleRepository : Repository<SampleDbContext>, ISampleRepository
{
public SampleRepository(SampleDbContext context) : base(context)
{
}
// Here you code to access Database
}
public class SampleRepositoryFactory : RepositoryFactory, ISampleRepositoryFactory
{
public SampleRepositoryFactory(IQueryScope queryScope) : base(queryScope)
{
}
public ISampleRepository GetSampleRepository() => new SampleRepository(new SampleDbContext());
public override IRepository GetRepository() => GetSampleRepository();
}
Step #2. Data annotation
[Table("OStatementBabyFile")]
[Schema("BABIES", "tempId")]
public class StatementBabyFileOriginalObject
{
public StatementBabyFileOriginalObject()
{
RowCreated = DateTime.UtcNow;
}
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public Guid tempId { get; set; }
[XmlProperty("NRECORDS")]
public int RowCount { get; set; }
[XmlProperty("SMOCOD")]
[MaxLength(10)]
public string Smo { get; set; }
[XmlProperty("FILENAME")]
[MaxLength(50)]
public string Name { get; set; }
[XmlProperty("VERS")]
[MaxLength(10)]
public string Version { get; set; }
public DateTime? RowCreated { get; set; }
}
[Table("OStatementBabyEntry")]
[Schema("BABY", "tempId", "BABIES", "upperId")]
public class StatementBabyEntryOriginalObject
{
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public Guid tempId { get; set; }
public Guid upperId { get; set; }
[MaxLength(50)]
[XmlProperty("FAM")]
public string LastName { get; set; }
[MaxLength(50)]
[XmlProperty("IM")]
public string FirstName { get; set; }
[MaxLength(50)]
[XmlProperty("OT")]
public string MiddleName { get; set; }
[XmlProperty("W")]
public long? SexId { get; set; }
[XmlProperty("DR")]
public DateTime? Birthday { get; set; }
[XmlProperty("MR")]
[MaxLength(500)]
public string PlaceOfBirth { get; set; }
}
[Table("OStatementBabyDocument")]
[Schema("DOC", "tempId", "BABY", "upperId")]
public class StatementBabyDocumentOriginalObject
{
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public Guid tempId { get; set; }
public Guid upperId { get; set; }
[XmlProperty("DOCTYPE")]
public int? DocumentId { get; set; }
[XmlProperty("DOCSER")]
[MaxLength(50)]
public string DocumentSerial { get; set; }
[XmlProperty("DOCNUM")]
[MaxLength(50)]
public string DocumentNumber { get; set; }
[XmlProperty("NAME_VP")]
[MaxLength(500)]
public string WhoIssue { get; set; }
[XmlProperty("DOCDATE")]
public DateTime? DocumentIssue { get; set; }
}
Step #3. Create and execute Sql queries
// Create repository factory
IPropertyScope propertyScope = new PropertyScope();
IQueryScope queryScope = new QueryScope(propertyScope);
using (ISampleRepositoryFactory repositoryFactory = new SampleRepositoryFactory(queryScope))
{
// Create entities
var fileList = new List<StatementBabyFileOriginalObject>()
{
new StatementBabyFileOriginalObject() { Name = "Sample1", Version = "1.0", RowCount = 3, RowCreated = DateTime.UtcNow }
};
var entryList = new List<StatementBabyEntryOriginalObject>()
{
new StatementBabyEntryOriginalObject() { LastName = "Иванов", FirstName = "Иван", MiddleName = "Иванович", Birthday = new DateTime(1990, 1, 1), SexId = 1 },
new StatementBabyEntryOriginalObject() { LastName = "Петров", FirstName = "Иван", MiddleName = "Иванович", Birthday = new DateTime(1991, 1, 1), SexId = 1 },
new StatementBabyEntryOriginalObject() { LastName = "Иванова", FirstName = "Светлана", MiddleName = "Ивановна", Birthday = new DateTime(1992, 1, 1), SexId = 2 }
};
// Create table in database and insert data
await repositoryFactory.ExecuteSqlWithTransactionAsync(
repositoryFactory.CreateTableToSql<StatementBabyFileOriginalObject>(),
repositoryFactory.CreateTableToSql<StatementBabyEntryOriginalObject>(),
repositoryFactory.AddToSql(fileList),
repositoryFactory.AddToSql(entryList)
);
}
Step #4. Xml file reader
using (var objectReader = new ObjectReader(scope))
{
objectReader
.handle<StatementBabyFileOriginalObject>(entities => repositoryFactory.BulkAddAsync(entities))
.handle<StatementBabyEntryOriginalObject>(entities => repositoryFactory.BulkAddAsync(entities));
objectReader.getObject(fileName);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Framework | net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.0
- Newtonsoft.Json (>= 12.0.2)
-
.NETFramework 4.8
- Newtonsoft.Json (>= 12.0.2)
- System.ComponentModel.Annotations (>= 4.5.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Simply.Property:
Package | Downloads |
---|---|
Simply.Property.SqlServer
This library build bulk sql command in single query. |
|
Simply.Property.XmlReader
This library performs xml to json conversion |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.3.12 | 1,160 | 4/12/2020 |
0.3.11 | 716 | 4/12/2020 |
0.3.10 | 500 | 12/2/2019 |
0.3.9 | 1,148 | 11/15/2019 |
0.3.8 | 708 | 11/15/2019 |
0.3.7 | 728 | 11/7/2019 |
0.3.6 | 939 | 10/25/2019 |
0.3.5 | 816 | 10/24/2019 |
0.3.4 | 499 | 10/24/2019 |
0.3.3 | 485 | 10/24/2019 |
0.3.2 | 480 | 10/24/2019 |
0.3.1 | 491 | 10/23/2019 |
0.3.0 | 485 | 10/22/2019 |
0.2.7 | 488 | 10/21/2019 |
0.2.6 | 503 | 10/21/2019 |
0.2.5 | 491 | 10/20/2019 |
0.2.4 | 512 | 10/18/2019 |
0.2.3 | 520 | 10/17/2019 |
0.2.2 | 529 | 10/17/2019 |
0.2.1 | 509 | 10/16/2019 |
0.2.0 | 480 | 10/16/2019 |
0.1.9 | 497 | 10/16/2019 |
0.1.8 | 519 | 10/16/2019 |
0.1.7 | 534 | 10/14/2019 |
0.1.6 | 564 | 10/14/2019 |
0.1.5 | 521 | 10/13/2019 |
0.1.4 | 507 | 9/27/2019 |
0.1.3 | 527 | 9/23/2019 |
0.1.2 | 510 | 9/23/2019 |
0.1.1 | 546 | 9/19/2019 |
0.1.0 | 516 | 9/19/2019 |