public void ListPartsTest() { int typID = 15270; // 525 i (192 HP) Modification int catID = 10142; // Аккум int badTypID = -1; int badCatID = -1; using( TecdocBaseDataContext ctx = new TecdocBaseDataContext() ) { XmlDocument doc = new XmlDocument(); try { var arr1 = ctx.ListParts( typID, catID ); Assert.IsTrue( arr1.Count > 0, "Вернулся пустой документ для возможных параметров" ); var arr2 = ctx.ListParts( badTypID, badCatID ); Assert.IsTrue( arr2.Count == 0, "Вернулся непустой документ для невозможных параметров" ); } catch( Exception e ) { if( e is AssertFailedException ) { throw; } else { Assert.Fail( String.Format( "Не могу загрузить список ЗЧ для {0}/{1}", typID, catID ) ); } } } }
public static List<PartsListItem> ListParts( int modificationId, int searchTreeNodeId ) { using( var ctx = new TecdocBaseDataContext() ) { var dlo = new DataLoadOptions(); dlo.LoadWith<Article>( a => a.ArticleNumber); dlo.LoadWith<Article>(a => a.Name); dlo.LoadWith<Article>(a => a.CompleteName); dlo.LoadWith<Article>(a => a.Supplier); ctx.LoadOptions = dlo; return ctx.ListParts( modificationId, searchTreeNodeId ).ToList(); } }