.


:




:

































 

 

 

 





 

_______________ ..

 

_________________2012 .

 

 

,
220400

 

 

   
,    
,    
   
,    
   
 

 

 

2014


681.3

: . . , . 230100 / . .. ; . : - , 2015. 18 .

 

 

_______________2015

 

. ., - . _________________..

 

 


1. . . . 5

. 5

. 7

.. 8

. 8

. 9

-.. 9

 


, 230100 . .

, . .

 


1. . .

.

. . - , . .

:

1. .

2. (, ).

3. .

4. () , (, , , .).

5. .

6. .

Microft Visual Studio . Windows Forms, . References () Solution explorer ( ).

() . . :

1. , .

2. .

3. .

4.

- . , . , , , , . .

:

1. () . , . .

2. . . . , RGB. (struct record).

3. , . .

4. , . : , , .

. , . ( , root) . (, , ). , , . -, , .

//

public class Person

{

public string PassportNumber;

public string Name;

public string Education;

public Address HomeAdress;

public List<Person> Friends;

public void AddFriend(Person p){.....}

public void Unfriend(Person p) {....}

}

 

// ( )

public struct Address

{

public string Street;

public string HouseNumber;
}

 

public class PersonRepository

{

public List<Person> Get(){....}

public void Save(Person p){....}

public void Delete(Person p){....}

}

 

//

public class FriendNotifier

{

public void Notify (Person p){

foreach (var item in p.Friends)

{

.....

}

}

}

 

:

public interface IGenericRepository<T> where T: class

{

 

IQueryable<T> GetAll();

IQueryable<T> FindBy(Expression<Func<T, bool>> predicate);

void Add(T entity);

void Delete(T entity);

void Edit(T entity);

void Save();

}

 

 

public class GenericRepository<T>:

IGenericRepository<T>

where T: class

{

 

private JobContext _entities;

public GenericRepository(string connectionString)

{

_entities = new JobContext(connectionString);

_entities.Database.Initialize(true);

}

 

 

public virtual IQueryable<T> GetAll()

{

 

IQueryable<T> query = _entities.Set<T>();

return query;

}

 

public IQueryable<T> FindBy(System.Linq.Expressions.Expression<Func<T, bool>> predicate)

{

 

IQueryable<T> query = _entities.Set<T>().Where(predicate);

return query;

}

 

public virtual void Add(T entity)

{

_entities.Set<T>().Add(entity);

}

 

public virtual void Delete(T entity)

{

_entities.Set<T>().Remove(entity);

}

 

public virtual void Edit(T entity)

{

_entities.Entry(entity).State = System.Data.EntityState.Modified;

}

 

public virtual void Save()

{

_entities.SaveChanges();

}

}

 





:


: 2016-12-31; !; : 340 |


:

:

, .
==> ...

1579 - | 1433 -


© 2015-2024 lektsii.org - -

: 0.02 .