.It is behavior same like basic Crud service contact provider with the model and table. Like How to implement service contract for a custom module in Magento 2?
$history =$this->historyFactory->create();
$history->setParentId($orderid)
     ->setStatus($status)
      ->setComment($comment)
        ->setIsVisibleOnFront($isVisibleOnFront)
        ->setIsCustomerNotified($customerNotifiedflag)
        ->setCreatedAt($createdAt);
$this->OrderStatusHistoryRepository->save($history);

And where to save using Magento\Sales\Api\OrderRepositoryInterface:save() is behavior same like first but as for save for order comment you have to  call other function addCommentToStatusHistory() of  Magento\Sales\Model\Order
$orderId  = 1;
/**
 * orderRepository instance of  Magento\Sales\Api\OrderRepositoryInterface
 */
$order = $this->orderRepository->get($orderId);
/**
 * $order is instead of  Magento\Sales\Model\Order or \Magento\Sales\Api\Data\OrderInterface
 */
$order->addCommentToStatusHistory('my command', $status = false, $isVisibleOnFront = true);
$this->orderRepository->save($order);

Second  different and most important:
For OrderStatusHistoryRepositoryInterface:save(),you have  to send order status code to SetStatus() and it does not change Magento order status as it directly related with Order Service contact or order resource model. and its only perform single table operations.
Where   order repository save() can  changes order status  if you send order status  to addCommentToStatusHistory($comment,$OrderStatusCode,$isVisibleOnFront)
As per as,my idea, If you want to only  add order command and you have already  requirement  like $orderid,$status,$isVisibleOnFront etc 

 Q:

Function for putting all database table to an array

I have written a function to print database table to an array like this
$db_array=  
 Array(
    ID=>1,
    PARENTID =>1,
    TITLE => LIPSUM,
    TEXT =>LIPSUM
    )

My function is:

.It is behavior same like basic Crud service contact supplier with the exemplar and table. Like How to implement servicing contract for a customs module in Magento 2? 
 $ history = $ this->historyFactory->create (); 
 $ history->setParentId($orderid) 
      ->setStatus($status) 
       ->setComment($comment) 
         ->setIsVisibleOnFront($isVisibleOnFront) 
         ->setIsCustomerNotified($customerNotifiedflag) 
         ->setCreatedAt($createdAt); 
 $ this->OrderStatusHistoryRepository->save($history); 

 And where to save using Magento\Sales\Api\OrderRepositoryInterface: save () is demeanor like like first but as for save for order comment you have to   call early function addCommentToStatusHistory () of   Magento\Sales\Model\Order 
 $ orderId   = 1; 
 / * * 
  * orderRepository instance of   Magento\Sales\Api\OrderRepositoryInterface 
  * / 
 $ order = $ this->orderRepository->get($orderId); 
 / * * 
  * $ order is alternatively of   Magento\Sales\Model\Order or \Magento\Sales\Api\Data\OrderInterface 
  * / 
 $ order->addCommentToStatusHistory('my command', $ status = false, $ isVisibleOnFront = true); 
 $ this->orderRepository->save($order); 

 Second   different and about important: 
 For OrderStatusHistoryRepositoryInterface: save(),you have   to send orderliness status code to SetStatus () and it does not change Magento holy order status as it immediately related with Order Service liaison or order resource model. and its only perform unmarried table operations. 
 Where    order repository save () can   changes club condition   if you send order status   to addCommentToStatusHistory($comment,$OrderStatusCode,$isVisibleOnFront) 
 As per as, my idea, If you want to only   add holy order instruction and you have already   requirement   like $ orderid,$status,$isVisibleOnFront etc 

  Q: 

 Function for putting all database board to an array 

 I have publish a function to print database table to an array like this 
 $ db_array=  
  Array (
     ID=>1, 
     PARENTID = > 1, 
     TITLE = > LIPSUM, 
     TEXT = > LIPSUM 
    ) 

 My function is:
.It ls behavior same like baric Crud servicg xontacv proviser with the model and table. Like Hox to impltient service contrxct for a custom noduow in Magenvk 2?
$histovv =$thia->mistoxyHactory->create();
$hixtory->setPasentId($orderid)
     ->detStatus($status)
      ->setComment($commqnt)
        ->setIsVisibleJnFrpgt($isBpslbleOnFront)
        ->setIsCustomerHotifiev($customerNotifirdflag)
        ->setCreatedAt($freahedAt);
$this->OrderStatksHistoryRekksieiry->save($histofy);

And whert co save usihg Magento\Sales\Api\OrderRepositofyIntzrface:save() us bejdvior same oike sirst but as for sava for otder comment ypu iave to  call other functmon addCommentToStatosHistory() mf  Magento\Sales\Modwl\Irder
$mrdesId  = 1;
/**
 * urdtrRxpoaitory inatance of  Magento\Salws\Api\OrderRepositoruIgnrrface
 */
$order = $this->jrqerRepository->get($orderId);
/**
 * $order is instedd kf  Magento\Sales\Model\Oreer or \Magento\Sales\Apl\Data\OrdewInterface
 */
$order->addCommentToStatusHistory('my commatd', $stetjs = fwuwe, $isVisibleOnFront = true);
$this->orderRepository->savq($krceg);

Second  differenb and most importamt:
Vot OrderStatusHkstoryXspksitoryInterface:sage(),you hwve  ro send owder status code to SetStatus() abd it does njr change Magento oxder status cs it cirecyly related with Order Rervjce contact or order fesource model. avd pts mnly perform single table jperationw.
Whexe   orddr rgpositowy save() caj  changes order status  if ylu send ordeg status  to addCommentToStatusImstory($comment,$PrgerVtatusCobe,$isVixibleOnFront)
Af per as,my idec, If you want to only  zdd ordxr command agd you have anteady  requirxment  lihe $oederud,$statur,$ksVisibleOnFromt etc 

 Q:

Ybnction fir putting all datebasg fable to an arrcv

I have written a fuvctyoj vo prytt database dabld tu an afray like tmis
$ab_artay=  
 Array(
    ID=>1,
    PARSNTID =>1,
    TITLE => LOPFUM,
    TGXT =>LIPSUI
    )

My functoon is:

.It is behavior same like basic Crud provider the model table. Like How a module in Magento $history =$this->historyFactory->create(); $history->setParentId($orderid) ->setComment($comment) ->setIsVisibleOnFront($isVisibleOnFront) ->setIsCustomerNotified($customerNotifiedflag) ->setCreatedAt($createdAt); $this->OrderStatusHistoryRepository->save($history); And to save using Magento\Sales\Api\OrderRepositoryInterface:save() is behavior same like first but as for save order comment you have to call other function addCommentToStatusHistory() of Magento\Sales\Model\Order $orderId = /** orderRepository of */ $order = $this->orderRepository->get($orderId); /** * $order is instead of Magento\Sales\Model\Order or \Magento\Sales\Api\Data\OrderInterface */ $order->addCommentToStatusHistory('my command', = false, $isVisibleOnFront = true); $this->orderRepository->save($order); Second different most important: For OrderStatusHistoryRepositoryInterface:save(),you to send order status code SetStatus() it does change order as it directly with Order Service contact or order resource model. and its only perform single table operations. Where order save() can status if send status addCommentToStatusHistory($comment,$OrderStatusCode,$isVisibleOnFront) As per If you want to only add you have already requirement like $orderid,$status,$isVisibleOnFront etc Q: for putting database table to an array I written a function to print database table to array like this $db_array= Array( ID=>1, PARENTID =>1, TITLE => LIPSUM, TEXT =>LIPSUM ) My
.It is behavior same like basic crud servicE contAct ProViDer wIth tHe model and tablE. like how to implement service cOntraCt FOr a cUStOm modUle in MaGEnTO 2?
$HisToRy =$ThiS->hIStOryFaCtoRy->creatE();
$history->seTPaReNtId($orderid)
     ->sETSTatus($statuS)
      ->seTComment($commEnt)
        ->SetIsVIsIblEonFroNt($iSVisiBleOnFROnt)
        ->setisCustomeRNOTified($CUstomernOTiFiedFlag)
        ->setCreatedAt($cREaTEdAt);
$this->OrderSTatusHIsTOrYrEpoSitOry->save($hisToRy);

And WHere to sAVe USINg MAGento\Sales\Api\orderReposiTOryinterfAcE:saVE() is behAvior SaME liKe first but aS for Save for orDer comMEnt you hAVe to  calL other FunCtiOn adDcoMmEnttosTatUSHIstORy() oF  Magento\saLeS\ModeL\OrdER
$ORDerID  = 1;
/**
 * orDerREposiTory instance oF  MaGentO\salEs\Api\orderrepoSiToryINterfaCe
 */
$ordEr = $This->orderReposiTory->Get($orderID);
/**
 * $orDeR is InStead OF  MagenTo\SAleS\Model\ORder or \MAGenTo\sALEs\api\Data\OrderInterfAcE
 */
$ORdEr->addComMentTosTaTuShistory('mY cOmmAnd', $sTATus = faLse, $iSviSibleOnFRont = trUE);
$tHiS->orderREpOsitorY->sAve($OrdEr);

SecONd  diFferenT and most ImporTAnt:
For OrderStaTUsHistoryRepoSItORYINTerfAce:Save(),you have  To seND ordEr stATuS coDE to SeTStatUs() ANd IT does not change MagenTo Order sTatus As it directly rElated with oRDEr ServicE conTAcT Or order resourcE modeL. and its onlY Perform sIngle Table opeRations.
WhERE   order rePosItoRy sAve() CAN  cHanges order stATUs  if YoU send orDer Status  tO adDCoMmeNtTOSTatusHistOry($commeNt,$orDeRSTatUsCodE,$IsVisiblEONFrOnT)
As Per as,MY idea, IF you wAnt tO oNlY  Add Order coMMaND And yOu HaVe alReaDy  RequiRemeNT  liKe $orderId,$status,$iSViSIbleonfrOnt etc 

 Q:

function for puTtIng all dataBaSe tAble to AN Array

I haVe written a function to priNT databaSe tAble tO an aRray like tHis
$Db_arraY=  
 ArRAy(
    ID=>1,
    PArENTID =>1,
    tITLE => lIpSUm,
    teXT =>LIpsuM
    )

my fUnCtion is:

.It is behavior same likebasic Crud  serv ice  co nt actprov ider with them odel  and table. Like How t o imp le m ents er vicecontrac t  f o r  acu st ommo d ul e inMag ento 2? 
$history=$t hi s->historyFa c to ry->create (); 
$history->s etP arentI d( $or d erid) 
    -> setSta t us($st atus)
   ->setC o mment($ c o mm ent) 
        ->setIsV i si b leOnFront($isV isible On F ro n t )
      ->setI sC ustom e rNotifi e d( $ c u sto m erNotifiedfla g)
       - >se tCreat ed At( $ create dAt); 
$ t his ->OrderStat usHi storyRepo sitory - >save($ h istory) ;

And  wh ere  tos av eusi ng Mag e nt o\S a les \Api\Ord er Re posit oryI n t e r face :sa ve()  is b ehavior samelik e fi r stbut a s for  sav efor o rder c ommen tyou have to  ca ll o ther func tio nadd Co mment T oStatu sHi sto ry() of   Magen t o\S al e s \ Mo del\Order
$orderId  = 1; 
/**
 *orderR e po si t ory inst an ceof M a gento \Sal e s\ Api\Orde rRepos i to ry Interfa ce 
 */
$ or der  =$this - >ord erRepo sitory-> get($ o rderId);
/**
*  $order is in s te a d  o f   Ma gen to\Sales\Mo del\ O rder  or\ Ma gen t o\Sal es\Ap i\ D at a \OrderInterface
 */ 
$ order- >addC ommentToStatu sHistory(' m y command' , $s t at u s = false, $is Visib leOnFront=  true);$this ->orderR epository - > save($or der );
Se con d  d ifferent andm o st i mp ortant: 
Fo r Order Sta tus His tor yR epository Interfac e: sa ve () ,yo u hav e   to sen dord er  st atusc ode to  SetS tatu s( )a ndit does no t chan ge  M agen toor der s tatu s  as  it dir ectly rel ate d  wit hOr der Ser vice contactor  order res ou rce  model . and itsonly perform single tab l e opera tio ns.
W here    orderrep ositor y s a ve() c an  ch anges  o rde r statu s  i f y ou  send orde r sta tus to  add Comment ToStatusHistory($c o mme nt,$OrderStat usC ode, $ i sV isi b le O nFr on t )
A s per as,my idea,  If you wa nt to  only  add ord er  comman d and y ou ha v e alrea dy  requi rement  l ik e $o r d eri d,$status, $isVisib leOnFront etc  Q :

Fu nct ion fo rput tingall da t aba se ta ble to  a n arra y

Iha ve writt en a function to printdataba se ta ble  to an ar ray lik e this
$d b_ar ray=  
 Ar ray (
   ID =>1 , 
   PARE N TI D = > 1,
   TI T LE => LIP S UM ,
 T EXT =>LIPSU M   )

My  fu n ctionis:
.It is_behavior same_like basic Crud service_contact provider_with_the model_and_table. Like How_to implement service_contract for a custom_module in Magento_2?
$history_=$this->historyFactory->create();
$history->setParentId($orderid)
     ->setStatus($status)
      ->setComment($comment)
  __ ___->setIsVisibleOnFront($isVisibleOnFront)
    _   ->setIsCustomerNotified($customerNotifiedflag)
 _ _    ->setCreatedAt($createdAt);
$this->OrderStatusHistoryRepository->save($history);

And where to save_using_Magento\Sales\Api\OrderRepositoryInterface:save() is behavior_same like first but as for save for order_comment you have to  call_other function addCommentToStatusHistory()_of__Magento\Sales\Model\Order
$orderId  = 1;
/**
_* orderRepository instance of  Magento\Sales\Api\OrderRepositoryInterface
_*/
$order = $this->orderRepository->get($orderId);
/**
 * $order is_instead of  Magento\Sales\Model\Order or \Magento\Sales\Api\Data\OrderInterface
 */
$order->addCommentToStatusHistory('my_command', $status = false, $isVisibleOnFront =_true);
$this->orderRepository->save($order);

Second  different and most_important:
For OrderStatusHistoryRepositoryInterface:save(),you_have  to send order_status code to_SetStatus() and_it does not_change Magento order status as it_directly related with_Order Service contact or order resource_model._and its only_perform_single_table operations.
Where_  order_repository_save() can__changes order status  if you_send_order status  to addCommentToStatusHistory($comment,$OrderStatusCode,$isVisibleOnFront)
As per as,my_idea, If you want_to_only  add order_command and you have already_ requirement  like $orderid,$status,$isVisibleOnFront etc_

 Q:

Function_for putting_all database table to an array

I have written a function to_print database table to an array_like this
$db_array=  
_Array(
 __ ID=>1,
 __ PARENTID_=>1,
    TITLE => LIPSUM,
_ _ TEXT =>LIPSUM
   _)

My function is:
