ParameterBase.CurrentUser.UserId
StringEnum<Ciphis.Enums.AccClass>.GetStringValue(Ciphis.Enums.AccClass.Vendor)
//创建Manager
ICustomerDeskDetailManager customerDeskDetailManager = ClientProxyFactory.CreateProxyInstance<ICustomerDeskDetailManager>();
//过滤条件
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(CustomerDeskDetailFields.DeskName == list[0].SysDeskName);
//在得到的EntityCollection中搜索相关数据
List<int> ids = customerDeskDetails.FindMatches(CustomerDeskDetailFields.TableName == item.TableName);
//关联查找
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.PurchaseOrderEntity);
IPrefetchPathElement2 element = prefetchPath.Add(PurchaseOrderEntity.PrefetchPathPurchaseOrderDetails);
element.SubPath.Add(PurchaseOrderDetailEntity.PrefetchPathPurchaseOrderBomDetails);
//添加排序条件
ISortExpression sortExpression = new SortExpression();
sortExpression.Add(CustomerDeskFields.SortNo | SortOperator.Ascending);
//添加关联关系
bucket.Relations.Add(InventoryMovementEntity.Relations.InventoryMovementDetailEntityUsingRefNo);//系统有外键,直接调用
bucket.Relations.Add(new EntityRelation(ItemFields.ItemNo, InventoryMovementDetailFields.ItemNo, RelationType.OneToMany), JoinHint.Left);//系统无外键,通过这种方式创建;JoinHint与写的顺序相反
//别名关联
bucket.Relations.Add(new EntityRelation(LocationFields.Loc,JobOrderMaterialPickFields.LocFrom, RelationType.OneToMany),"LocFrom", JoinHint.Left);//主实体必须放在后面
//多建关联
IEntityRelation mulKeyRelation = new EntityRelation(JobOrderMaterialPickDetailFields.SourceRefNo, PurchaseOrderDetailFields.OrderNo, RelationType.ManyToOne);
mulKeyRelation.AddEntityFieldPair(JobOrderMaterialPickDetailFields.SourceEntryNo, PurchaseOrderDetailFields.EntryNo);
bucket.Relations.Add(mulKeyRelation, JoinHint.Right);//系统无外键,通过这种方式创建
//复杂的公式
DbFunctionCall dbFunQtyReceipt = new DbFunctionCall("ISNULL", new object[] { (PurchaseReceiptsDetailFields.QtyReceipt), 0 });
DbFunctionCall dbFunQtyCosting = new DbFunctionCall("ISNULL", new object[] { (PurchaseReceiptsDetailFields.QtyCosting), 0 });
EntityField2 eQtyReceipt = new EntityField2("QtyReceipt", dbFunQtyReceipt);
EntityField2 eQtyCosting = new EntityField2("QtyCosting", dbFunQtyCosting);
bucketInspection.PredicateExpression.Add(new FieldCompareExpressionPredicate(eQtyReceipt, null, ComparisonOperator.GreaterThan, new Expression(eQtyCosting)));
//保存时不验证
entity.Validator = null;
adapter.SaveEntity(entity, true, false);
//创建对象
IRelationPredicateBucket bucket = e.Argument as IRelationPredicateBucket;
//读取哪些列
ExcludeIncludeFieldsList fields = new ExcludeIncludeFieldsList(false);
fields.Add(FiscalPeriodFields.EndDate);
//添加需要读取的字段【!!必须按顺序,必须数量等于条数】
ResultsetFields fields = new ResultsetFields(4);
fields.DefineField(InventoryMovementFields.RefNo, 0);
fields.DefineField(InventoryMovementFields.LocFrom, 1);
fields.DefineField(ProductionInspectionFields.JobNo, 3, "InspectionJobNo");//关联表的数据,以及创建别名
//添加Where条件
bucket.PredicateExpression.Add(InventoryMovementFields.SourceType ==
StringEnum<Ciphis.Enums.TransactionType>.GetStringValue(Ciphis.Enums.TransactionType.ProductionInspection));
//判断是否为空
bucket.PredicateExpression.Add(JobOrderMaterialPickDetailFields.SourceEntryNo == DBNull.Value);
//获取
IUserDefinedQueryManager userDefinedQueryManager = ClientProxyFactory.CreateProxyInstance<IUserDefinedQueryManager>();
_productionIssueTable = userDefinedQueryManager.GetQueryResult(fields, bucket, sortExpression, null, true, 0, false);
//直接删除 Delete From A Where
IRelationPredicateBucket bucket = new RelationPredicateBucket((CustomerFields.CustomerID == "FISSA"));
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.DeleteEntitiesDirectly("CustomerEntity", bucket);
//事务
using (DataAccessAdapterBase adapter = GetCompanyDataAccessAdapter())
{
try{
adapter.StartTransaction(IsolationLevel.ReadCommitted, "SalesShipmentImportOrder");
使用LLBL基本的语句写
adapter.Commit();
}
catch
{
adapter.Rollback();
throw;
}
//直接更新 Update A set Where
var ShipmentImportTmpChangedEntity = new ShipmentImportTmpEntity();
ShipmentImportTmpChangedEntity.TransactionType = "FeedBack";//直接赋值
ShipmentImportTmpChangedEntity.Fields[(int)ShipmentImportTmpFieldIndex.TransactionType].ExpressionToApply =
new Expression(ShipmentImportTmpFields.PaymentType);//等于另外一个字段
ShipmentImportTmpChangedEntity.Fields[(int)ShipmentImportTmpFieldIndex.TransactionType].ExpressionToApply =
(ShipmentImportTmpFields.PaymentType + ShipmentImportTmpFields.TransactionType);//等于表达式
IRelationPredicateBucket bucket2 = new RelationPredicateBucket();
bucket2.PredicateExpression.Add(ShipmentImportTmpFields.PaymentType == "Amazon fees");
adapter.UpdateEntitiesDirectly(ShipmentImportTmpChangedEntity, bucket2);
//实际应该把其他的值设置为false,防止同时更新,然后使用currentValue赋值,防止发生连带赋值
InventoryMovementDetailEntity updateMovDetails = new InventoryMovementDetailEntity();
foreach (IEntityField2 field in updateMovDetails.Fields) { field.IsChanged = false; }
updateMovDetails.Fields[(int)InventoryMovementDetailFieldIndex.CreatedDate].CurrentValue = DateTime.Now;
adapter.UpdateEntitiesDirectly(updateMovDetails, bucket);
//复杂代码
IRelationPredicateBucket bucket = new RelationPredicateBucket();
Foundation.HelperClasses.ResultsetFields fields = new Foundation.HelperClasses.ResultsetFields(2);
DbFunctionCall dbFunQtyOnHand = new DbFunctionCall("isnull({0},0) - isnull({1},0)",
new object[] { (InventoryBalanceFields.QtyOnHand), (InventoryBalanceFields.QtyReserved) });
EntityField2 eQtyBalance = new EntityField2("QtyBalance", dbFunQtyOnHand);
fields.DefineField(eQtyBalance, 0);
fields[0].SetAggregateFunction(AggregateFunction.Sum);
fields.DefineField(InventoryBalanceFields.ItemNo, 1);
ISortExpression sortExpression = new SortExpression();
IUserDefinedQueryManager userDefinedQueryManager = ClientProxyFactory.CreateProxyInstance<IUserDefinedQueryManager>();
IGroupByCollection groupByCollection = new GroupByCollection();
groupByCollection.Add(fields[1]);
DataTable table = userDefinedQueryManager.GetQueryResult(fields, bucket, sortExpression, groupByCollection, true, 0, false);
table.PrimaryKey = new DataColumn[] { table.Columns[InventoryBalanceFields.ItemNo.Name] };
return table;
LLBL Gen 基本代码操作
最新推荐文章于 2022-12-05 11:30:39 发布