/// <summary> /// Create a ViewModel, and pass Session,cache,dc...etc to the viewmodel /// </summary> /// <typeparam name="T">The type of the viewmodelThe type of the viewmodel</typeparam> /// <param name="Id">If the viewmodel is a BaseCRUDVM, the data having this id will be fetched</param> /// <param name="values">properties of the viewmodel that you want to assign values</param> /// <param name="passInit">if true, the viewmodel will not call InitVM internally</param> /// <returns>ViewModel</returns> public T CreateVM <T>(object Id, Expression <Func <T, object> > values = null, bool passInit = false) where T : BaseVM { SetValuesParser p = new SetValuesParser(); var dir = p.Parse(values); return(CreateVM(typeof(T), Id, new object[] { }, dir, passInit) as T); }
/// <summary> /// Create a ViewModel, and pass Session,cache,dc...etc to the viewmodel /// </summary> /// <typeparam name="T">The type of the viewmodelThe type of the viewmodel</typeparam> /// <param name="Ids">If the viewmodel is a BatchVM, the BatchVM's Ids property will be assigned</param> /// <param name="values">use Lambda to set viewmodel's properties,use && for multiply properties, for example CreateVM<Test>(values: x=>x.Field1=='a' && x.Field2 == 'b'); will set viewmodel's Field1 to 'a' and Field2 to 'b'</param> /// <param name="passInit">if true, the viewmodel will not call InitVM internally</param> /// <returns>ViewModel</returns> public T CreateVM <T>(string[] Ids, Expression <Func <T, object> > values = null, bool passInit = false) where T : BaseVM { SetValuesParser p = new SetValuesParser(); var dir = p.Parse(values); return(CreateVM(typeof(T), null, Ids.Cast <object>().ToArray(), dir, passInit) as T); }
public T CreateVM <T>(Guid?Id = null, Guid[] Ids = null, Expression <Func <T, object> > values = null, bool passInit = true) where T : BaseVM { SetValuesParser p = new SetValuesParser(); var dir = p.Parse(values); return(CreateVM(typeof(T), Id, Ids, dir, passInit) as T); }