Create
Table Of Contents
Create Method
To create entities in the data store you will need to call the Create method on the entity's repository.
The Sharp Factory App generates one Repository per entity.
You will need an instance of the RepositoryContainer class to access your repositories.
The naming convention is RepositoryContainer.{Model Name}.{Sql Schema Name}.{Entity Name}.Create
The Create method has two overloads:
-
The first one takes an entity to be created.
This overload returns a boolean. True if succeeded, otherwise false.
Throws an exception if the value passed in is null.
-
The second overload takes a list of entities and returns void.
Throws an exception if the list passed in is null.
Throws an exception if it fails to create one entity.
Throws an exception if any entity in the list is null.
Any property that is generated at the database like Identity will be populated after calling Create.
Create Single
The following sample of C# code shows how to create a Customer entity in the database:
Create List
To create a list you can just pass a List
The following sample of C# code shows how to create a list of customer in the database: