AccountRepository.GetAccountByID C# (CSharp) Method

GetAccountByID() public method

public GetAccountByID ( int accountID ) : Account
accountID int
return Account
    	public Account GetAccountByID(int accountID)
    	{
    		Account result = null;
    
    		using(MyDataContext dc = new ConnectionFactory.GetConnection(Databases.DB1))
    		{
    			result = dc.Accounts.Where(a=>a.AccountID == accountID).FirstOrDefault();
    		}
    		
    		//result is null...go to the other database to get an Account
    		if(result == null)
    		{
    			using(MyDataContext dc = new ConnectionFactory.GetConnection(Databases.DB2))
    			{
    				result = dc.Accounts.Where(a=>a.AccountID == accountID).FirstOrDefault();
    			}
    		}
    
    		return result;
    
    		}
    	}

Usage Example

Beispiel #1
0
        public Account GetAccountByID(long accountID)
        {
            AccountRepository accRep  = new AccountRepository();
            Account           account = accRep.GetAccountByID(accountID);

            return(account);
        }
All Usage Examples Of AccountRepository::GetAccountByID
AccountRepository