Bedouin wrote:
MS-SQL: select SUM(Miktar*BirimFiyati)/SUM(Miktar) as Toplam,Kodu
From Fisler
where HareketTuru = '2' or
HareketTuru = '3' or
HareketTuru = '5'
group by Kodu
Normally, I put returning value to the dataset.than I take from dataset and put this result to the another table.
llblgen :
ResultsetFields fields = new ResultsetFields(1);
MalzemeYonetimiStokFisHareketleriCollection col = new MalzemeYonetimiStokFisHareketleriCollection();
IPredicateExpression A = new PredicateExpression();
A.Add(PredicateFactory.CompareValue(FislerFieldIndex.HareketTuru,ComparisonOperator.Equal,"2"));
A.AddWithOr(PredicateFactory.CompareValue(FislerFieldIndex.HareketTuru,ComparisonOperator.Equal,"3"));
A.AddWithOr(PredicateFactory.CompareValue(FislerFieldIndex.HareketTuru,ComparisonOperator.Equal,"5"));
GroupByCollection groupBy = new GroupByCollection();
groupBy.Add(EntityFieldFactory.Create(FislerFieldIndex.Kodu));
IExpression Tutar = new Expression(FislerFieldIndex.Miktar,ExOp.Mul,EntityFieldFactory.Create(FislerFieldIndex.BirimFiyati));
fields[0].ExpressionToApply = Tutar;
fields[0].AggregateFunctionToApply = AggregateFunction.Sum;
int i=1;
IExpression SonucMiktar = new Expression(i,ExOp.Mul,EntityFieldFactory.Create(FislerFieldIndex.Miktar));
fields[1].ExpressionToApply = SonucMiktar;
fields[1].AggregateFunctionToApply = AggregateFunction.Sum;
IExpression GenelSonuc= new Expression(fields[0],ExOp.Div,fields[1]);
i define the datatable for put this value to it, but i gives reference error. which reference can i use for it?
What error exactly do you get and when? That information would be very helpful
Beside That,I write the sentence like that.is it true or not i don't know.
I dont use the filter up to now because i want to put returning values to the another entity.how can i define the this entity and how can i defie the values for this entitiy.
You mean if your expression code is correctly doing what you want to do in SQL?
I think your code should be:
ResultsetFields fields = new ResultsetFields(2);
MalzemeYonetimiStokFisHareketleriCollection col = new MalzemeYonetimiStokFisHareketleriCollection();
IPredicateExpression A = new PredicateExpression();
A.Add(PredicateFactory.CompareValue(FislerFieldIndex.HareketTuru,ComparisonOperator.Equal,"2"));
A.AddWithOr(PredicateFactory.CompareValue(FislerFieldIndex.HareketTuru,ComparisonOperator.Equal,"3"));
A.AddWithOr(PredicateFactory.CompareValue(FislerFieldIndex.HareketTuru,ComparisonOperator.Equal,"5"));
Expression mulEx = new Expression(
EntityFieldFactory.Create(FislerFieldIndex.Miktar), ExOp.Mul,
EntityFieldFactory.Create(FislerFieldIndex.BrimFiyati));
EntityField op1 = EntityFieldFactory.Create(FislerFieldIndex.Miktar);
op1.ExpressionToUse = mulEx;
op1.AggregateFunctionToUse = AggregateFunction.Sum;
EntityField op2 = EntityFieldFactory.Create(FislerFieldIndex.Miktar);
op2.AggregateFunctionToUse = AggregateFunction.Sum;
Expression divEx = new Expression(op1, ExOp.Div, op2);
fields.DefineField(FislerFieldIndex.Miktar, 0, "Toplam");
fields.DefineField(FislerFieldIndex.Kodu, 1, "Kodu);
fields[0].ExpressionToUse = divEx;
GroupByCollection groupBy = new GroupByCollection();
groupBy.Add(fields[0]);
The somewhat weird way to set up the expression will be addressed in 1.0.2005.1 with operator overloading so you can design the expressions in a more intuitive way.