You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-39Lines changed: 40 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,17 +13,6 @@ In order to perform database CRUD operation from .net application,
13
13
the wrapper makes it quite easy by following the below steps.
14
14
```
15
15
16
-
#### Application list and details
17
-
18
-
| App Name| Type | Comments|
19
-
| --- | --- | --- |
20
-
| Generic.Repository.EntityFramework| Class Library | EntityFramework wrapping business logic|
21
-
| Generic.Repository.EntityFramework.Test| Test App |unit tests |
22
-
| Generic.Repository.EntityFramework.ConsoleApp.Test | Console |Test the wrapping business logic |
23
-
24
-
> nuget package **"Generic.Repository.EntityFramework"** is a wrapper around ORM EntityFramework
25
-
26
-
<hr />
27
16
28
17
#### Steps to use the [](https://www.nuget.org/packages/Generic.Repository.EntityFramework) package
29
18
@@ -38,54 +27,66 @@ IDbContext type is inherited from the installed [ : base("name=connectionstring"){}
43
-
IDbSet<T> IDbContext.Set<T>()
44
-
{
45
-
return base.Set<T>();
46
-
}
47
-
public DbSet<Customer> Customers {get;set;}
48
-
public int Save()
49
-
{
50
-
return base.SaveChanges();
51
-
}
52
-
....
53
-
}
30
+
{
31
+
public DB() : base("name=connectionstring"){}
32
+
IDbSet<T> IDbContext.Set<T>()
33
+
{
34
+
return base.Set<T>();
35
+
}
36
+
public DbSet<Customer> Customers {get;set;}
37
+
public int Save()
38
+
{
39
+
return base.SaveChanges();
40
+
}
41
+
....
42
+
}
54
43
```
55
44
> 3. Now all set, please add the below lines from your consuming object/component
56
45
57
46
```
58
-
using Generic.Repository.EntityFramework;using Unity; //add these 2 references
47
+
//add these 2 references
48
+
using Generic.Repository.EntityFramework;
49
+
using Unity;
50
+
59
51
public class ConsumeService
60
52
{
61
53
...
62
54
void ConsumeMethod()
63
-
{
64
-
//get the Unity container
65
-
var container = UnityConfig.Container;
66
-
67
-
// register your 'DataModel'
68
-
container.RegisterType<IDbContext, DB>();
55
+
{
56
+
var container = UnityConfig.Container; //get the Unity container
57
+
58
+
container.RegisterType<IDbContext, DB>(); // register your 'DataModel'
69
59
70
60
var dbManager=container.Resolve<IDBManager>(); //get the db manager
71
61
72
-
//All wired up !!!
73
-
DO YOUR CRUD OPERATION & Customer is the table name in DB;
62
+
//All wired up. DO YOUR CRUD OPERATION & Customer is the table name in DB
74
63
75
-
//GET
76
-
var result=dbManager.GetRepository<Customer>().Get();
64
+
var result=dbManager.GetRepository<Customer>().Get(); //GET All
77
65
78
66
//FIND by id, where id is the primary key
79
67
var result=dbManager.GetRepository<Customer>().Find(id);
80
68
81
-
// ADD, custObj is the Customer object
82
-
var result=dbManager.GetRepository<Customer>().Add(custObj);
69
+
// custObj is the Customer object
70
+
var result=dbManager.GetRepository<Customer>().Add(custObj); //ADD
83
71
84
-
// DELETE, custObj is the Customer object
85
-
var result=dbManager.GetRepository<Customer>().Delete(custObj);
72
+
var result=dbManager.GetRepository<Customer>().Update(custObj); // UPDATE
73
+
74
+
var result=dbManager.GetRepository<Customer>().Delete(custObj); // DELETE
86
75
}
87
76
```
88
77
78
+
#### Application list and details
79
+
80
+
| App Name| Type | Comments|
81
+
| --- | --- | --- |
82
+
| Generic.Repository.EntityFramework*| Class Library | EntityFramework wrapping business logic|
83
+
| Generic.Repository.EntityFramework.Test| Test App |unit tests |
84
+
| Generic.Repository.EntityFramework.ConsoleApp.Test | Console |Test the wrapping business logic |
85
+
86
+
> *nuget package **"Generic.Repository.EntityFramework"** is a wrapper around ORM EntityFramework
87
+
88
+
<hr />
89
+
89
90
### Support or Contact
90
91
91
92
Having any trouble? Check out our [documentation](https://github.com/AJEETX/Generic.Repository.EntityFramework/blob/master/README.md) or [contact support](mailto:[email protected]) and we’ll help you sort it out.
0 commit comments