コード例 #1
0
ファイル: Program-2.cs プロジェクト: SenerDemiral/M2
        public override Task <TblaProxy> TblaUpdate(TblaProxy request, ServerCallContext context)
        {
            var result = new TblaProxy
            {
                RowPk   = request.RowPk,
                FldStr  = request.FldStr,
                FldDbl  = request.FldDbl,
                FldDcm  = request.FldDcm,
                FldDate = request.FldDate,
                FldInt  = request.FldInt
            };

            TblaProxy proxy = null;

            Scheduling.RunTask(() =>
            {
                // RowState: Added, Modified, Deletede, Unchanged
                Db.TransactAsync(() =>
                {
                    if (request.RowState == "A" || request.RowState == "M")
                    {
                        M2DB.TblB row = ReflectionExample.FromProxy <TblaProxy, M2DB.TblB>(request);
                        proxy         = ReflectionExample.ToProxy <TblaProxy, M2DB.TblB>(row);
                    }
                    else if (request.RowState == "D")
                    {
                        result.RowPk = request.RowPk;
                        var rec      = Db.FromId(request.RowPk) as M2DB.TblA;
                        if (rec == null)
                        {
                            result.RowErr = "TblA Rec not found";
                        }
                        else
                        {
                            rec.Delete();
                        }
                    }
                });
            }).Wait();

            return(Task.FromResult(proxy));
        }
コード例 #2
0
ファイル: Program-2.cs プロジェクト: SenerDemiral/M2
        public async Task TblaFill2(QryProxy request, IServerStreamWriter <TblaProxy> responseStream, ServerCallContext context)
        {
            var proxy = new TblaProxy();

            proxy.RowPk = 1;

            await Scheduling.RunTask(() =>
            {
                for (int i = 0; i < 1000; i++)
                {
                    Task.Run(async() =>
                    {
                        foreach (var row in Db.SQL <M2DB.TblB>("select r from TblB r"))
                        {
                            proxy = ReflectionExample.ToProxy <TblaProxy, M2DB.TblB>(row);

                            await responseStream.WriteAsync(proxy);
                        }
                    }).Wait();

                    //await responseStream.WriteAsync(proxy);
                }
            });
        }