当前位置: 首页>>代码示例>>C#>>正文


C# IQueryable.OfType方法代码示例

本文整理汇总了C#中IQueryable.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.OfType方法的具体用法?C# IQueryable.OfType怎么用?C# IQueryable.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQueryable的用法示例。


在下文中一共展示了IQueryable.OfType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsInList

        public virtual bool IsInList(IQueryable<Article> arts)
        {
            var sel = arts.OfType<Printable>();
            var cont = (sel.Where(c => c.NameOfMaterial == this.NameOfMaterial &&
                c.TypeOfMaterial == this.TypeOfMaterial &&
                c.Weight == this.Weight &&
                c.Adhesive == this.Adhesive &&
                c.Color == this.Color).Count());

            return (cont > 0);
        }
开发者ID:algola,项目名称:backup,代码行数:11,代码来源:ProductPartsPrintableArticleEx.cs

示例2: InitCostDetail

        public override void InitCostDetail(IQueryable<TaskExecutor> tskExec, IQueryable<Article> articles)
        {
            if (!justInited)
            {
                base.InitCostDetail(tskExec, articles);
                String codTypeOfTask = String.Empty;
                Console.WriteLine(ProductPart); //= TaskCost.ProductPartTask.ProductPart;
                codTypeOfTask = TaskCost.ProductPartTask.OptionTypeOfTask.CodTypeOfTask;
                tskExec = TaskExecutor.FilterByTask(tskExec, codTypeOfTask);
                TaskExecutors = tskExec.ToList();

                ICollection<ProductPartsPrintableArticle> productPartPrintabelArticles = new List<ProductPartsPrintableArticle>();

                productPartPrintabelArticles = TaskCost.ProductPartTask.ProductPart.ProductPartPrintableArticles;

                #region Format
                List<string> formats = new List<string>();
                //
                //voglio sapere quali sono i formati degli articoli ma gli articoli che posso stampare dipendono dal tipo di macchina!!!!
                foreach (var item in productPartPrintabelArticles)
                {
                    //accomunano lo stesso tipo!!!
                    var CurTskE = tskExec.FirstOrDefault();

                    if (CurTskE.TypeOfExecutor == TaskExecutor.ExecutorType.LithoSheet ||
                        CurTskE.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                    {
                        var formatList = articles.OfType<SheetPrintableArticle>()
                                    .Where(x => x.TypeOfMaterial == item.TypeOfMaterial &&
                                        x.Color == item.Color &&
                                        x.Adhesive == item.Adhesive &&
                                        x.NameOfMaterial == item.NameOfMaterial)
                                            .Select(x => x.Format);

                        formats = formats.Union(formatList.ToList()).ToList();

                    }

                    if (CurTskE.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterSheet)
                    {
                        var formatList = articles.OfType<RigidPrintableArticle>()
                                    .Where(x => x.TypeOfMaterial == item.TypeOfMaterial &&
                                        x.Color == item.Color &&
                                        x.Adhesive == item.Adhesive &&
                                        x.NameOfMaterial == item.NameOfMaterial)
                                            .Select(x => x.Format);

                        formats = formats.Union(formatList.ToList()).ToList();
                    }

                }

                BuyingFormats = formats;

                #endregion

            }
        }
开发者ID:algola,项目名称:backup,代码行数:58,代码来源:PrintingSheetCostDetail.cs

示例3: MakeCostDetail


//.........这里部分代码省略.........

                                //TODO: E' da calcolare il formato di stampa a seconda del formato macchina
                                ((PrintingRollCostDetail)cv).PrintingFormat =
                                    (((PrintingRollCostDetail)cv).PrintingFormat == "" || ((PrintingRollCostDetail)cv).PrintingFormat == null) ?
                                    ((PrintingRollCostDetail)cv).BuyingFormat
                                    : ((PrintingRollCostDetail)cv).PrintingFormat;
                            }

                            break;


                        case TaskExecutor.ExecutorType.PlotterSheet:
                            cv = new PrintingSheetCostDetail();

                            cv.TaskCost = this;
                            cv.InitCostDetail(tskExecs, articles);

                            ((PrintingSheetCostDetail)cv).BuyingFormat =
                                 (((PrintingSheetCostDetail)cv).BuyingFormat == "" || ((PrintingSheetCostDetail)cv).BuyingFormat == null) ?
                                 (((PrintingSheetCostDetail)cv).BuyingFormats != null) && (((PrintingSheetCostDetail)cv).BuyingFormats.Count > 0) ? ((PrintingSheetCostDetail)cv).BuyingFormats.FirstOrDefault() : null
                                 : ((PrintingSheetCostDetail)cv).BuyingFormat;

                            //TODO: E' da calcolare il formato di stampa a seconda del formato macchina
                            ((PrintingSheetCostDetail)cv).PrintingFormat =
                                (((PrintingSheetCostDetail)cv).PrintingFormat == "" || ((PrintingSheetCostDetail)cv).PrintingFormat == null) ?
                                ((PrintingSheetCostDetail)cv).BuyingFormat
                                : ((PrintingSheetCostDetail)cv).PrintingFormat;


                            cv.SetTaskexecutor(tskExecs, codTaskExecutor);

                            break;



                        case TaskExecutor.ExecutorType.Flexo:
                        case TaskExecutor.ExecutorType.FlatRoll:

                            cv = new PrintingZRollCostDetail();

                            cv.TaskCost = this;
                            cv.InitCostDetail(tskExecs, articles);

                            cv.SetTaskexecutor(tskExecs, codTaskExecutor);

                            cv.ProductPart = productPart;

                            ((PrintingZRollCostDetail)cv).DieTollerance = 0.5;
                            //qui voglio solo le fustelle flexo e semiroll
                            ((PrintingZRollCostDetail)cv).Dies = articles.OfType<Die>().ToList();

                            //search valid formats
                            ((PrintingZRollCostDetail)cv).FuzzyAlgo();

                            ((PrintingZRollCostDetail)cv).BuyingFormat =
                                 (((PrintingZRollCostDetail)cv).BuyingFormat == "" || ((PrintingZRollCostDetail)cv).BuyingFormat == null) ?
                                 (((PrintingZRollCostDetail)cv).BuyingFormats != null) && (((PrintingZRollCostDetail)cv).BuyingFormats.Count > 0) ? ((PrintingZRollCostDetail)cv).BuyingFormats.FirstOrDefault() : null
                                 : ((PrintingZRollCostDetail)cv).BuyingFormat;

                            //TODO: E' da calcolare il formato di stampa a seconda del formato macchina
                            ((PrintingZRollCostDetail)cv).PrintingFormat =
                                (((PrintingZRollCostDetail)cv).PrintingFormat == "" || ((PrintingZRollCostDetail)cv).PrintingFormat == null) ?
                                ((PrintingZRollCostDetail)cv).BuyingFormat
                                : ((PrintingZRollCostDetail)cv).PrintingFormat;



                            break;

                        case TaskExecutor.ExecutorType.PrePostPress:
                            break;
                        case TaskExecutor.ExecutorType.Binding:
                            break;
                        default:
                            break;
                    }

                }
                else
                {
                    //
                    var e = new NoTaskExecutorException();
                    e.Data.Add("CodTypeOfTask", codTypeOfTask);
                    throw e;

                }


                cv.ProductPart = productPart;


                cv.TaskCost = this;
                cv.CodCost = this.CodCost;
                cv.CodCostDetail = this.CodCost;
            }

            #endregion

            return cv;
        }
开发者ID:algola,项目名称:backup,代码行数:101,代码来源:CostEx.cs

示例4: InitCostDetail

        public override void InitCostDetail(IQueryable<TaskExecutor> tskExec, IQueryable<Article> articles)
        {
            if (!justInited)
            {
                base.InitCostDetail(tskExec, articles);

                _articles = articles.ToList().AsQueryable();

                String codTypeOfTask = String.Empty;
                //Console.WriteLine(ProductPart); //= TaskCost.ProductPartTask.ProductPart;
                codTypeOfTask = TaskCost.ProductPartTask.OptionTypeOfTask.CodTypeOfTask;
                tskExec = TaskExecutor.FilterByTask(tskExec, codTypeOfTask);
                TaskExecutors = tskExec.ToList();

                ICollection<ProductPartsPrintableArticle> productPartPrintabelArticles = new List<ProductPartsPrintableArticle>();
                productPartPrintabelArticles = TaskCost.ProductPartTask.ProductPart.ProductPartPrintableArticles;


                #region Format
                List<string> formats = new List<string>();
                var widthList = new List<Nullable<double>>();

                //
                //voglio sapere quali sono i formati degli articoli ma gli articoli che posso stampare dipendono dal tipo di macchina!!!!
                foreach (var item in productPartPrintabelArticles)
                {
                    widthList = articles.OfType<RollPrintableArticle>()
                               .Where(x => x.TypeOfMaterial == item.TypeOfMaterial &&
                                   x.Color == item.Color &&
                                   x.Adhesive == item.Adhesive &&
                                   x.Weight == item.Weight &&
                                   x.NameOfMaterial == item.NameOfMaterial)
                                       .Select(x => x.Width).ToList();
                }

                //FLAT
                //***********************************************
                foreach (var width in widthList)
                {
                    if (BuyingWidths == null) BuyingWidths = new List<double>();
                    BuyingWidths.Add(width ?? 0);
                }


                //FLEXO
                //**********************************************
                var tskCurrent = tskExec.FirstOrDefault(x => x.CodTaskExecutor == CodTaskExecutorSelected);
                if (tskCurrent == null)
                {
                    tskCurrent = tskExec.FirstOrDefault();
                }

                var zList = new List<string>();

                foreach (var item in tskCurrent.TaskExecutorCylinders)
                {
                    if (tskCurrent.TypeOfExecutor == TaskExecutor.ExecutorType.Flexo)
                    {
                        zList.Add(
                            ((Flexo)tskCurrent).GetCmFromZ(item.Z ?? 0).ToString());
                    }
                    else
                    {
                        zList.Add((Convert.ToDouble(item.Z) / 8 * 2.54).ToString());
                    }
                }

                //combino i width con gli Z

                foreach (var width in widthList.Where(x => x != 0))
                {
                    foreach (var z in zList)
                    {
                        var x = (width ?? 0).ToString("0.00", Thread.CurrentThread.CurrentUICulture) + "x" + z;
                        if (!formats.Contains(x))
                            formats.Add((width ?? 0).ToString("0.00", Thread.CurrentThread.CurrentUICulture) + "x" + z);
                    }
                }

                BuyingFormats = formats;
                //**********************************************

                #endregion

            }
        }
开发者ID:algola,项目名称:backup,代码行数:86,代码来源:PrintingZRollCostDetail.cs

示例5: FilterByTask

        /// <summary>
        /// filters whitch taskexecutor can run codTypeOfTask task
        /// </summary>
        /// <param name="codTypeOfTask"></param>
        /// <returns></returns>
        public static IQueryable<TaskExecutor> FilterByTask(IQueryable<TaskExecutor> tskExecList, string codTypeOfTask)
        {

            if (codTypeOfTask == "TAVOLOCONTROLLO")
            {
                tskExecList = tskExecList.OfType<ControlTableRoll>();
            }

            if (codTypeOfTask == "STAMPARIGIDO")
            {
                tskExecList = tskExecList.OfType<PlotterSheet>();
            }

            if (codTypeOfTask == "STAMPAMORBIDO")
            {
                tskExecList = tskExecList.OfType<PlotterRoll>();
            }

            if (codTypeOfTask == "STAMPAOFF")
            {
                tskExecList = tskExecList.OfType<LithoSheet>();
            }

            if (codTypeOfTask == "STAMPAOFFeDIGITALE" || codTypeOfTask == "STAMPANEW")
            {
                var tskExec1 = tskExecList.OfType<LithoSheet>();
                var tskExec2 = tskExecList.OfType<DigitalSheet>();

                tskExecList = tskExec1.Union<TaskExecutor>(tskExec2);
            }

            //CodTypeOfTask
            if (codTypeOfTask == "STAMPAETICHROTOLO")
            {
                var tskExec1 = tskExecList.OfType<Flexo>();
                var tskExec2 = tskExecList.OfType<FlatRoll>();

                tskExecList = tskExec1.Union<TaskExecutor>(tskExec2);
                //                tskExecList = tskExecList.OfType<FlatRoll>();

            }


            //CodTypeOfTask
            if (codTypeOfTask == "SERIGRAFIAROTOLO")
            {
                //   var tskExec1 = tskExecList.OfType<Flexo>();
                //   var tskExec2 = tskExecList.OfType<ControlTableRoll>();

                tskExecList = tskExecList.OfType<FlatRoll>().Where(x => x.Serigraphy ?? false);
            }


            //CodTypeOfTask
            if (codTypeOfTask == "STAMPAACALDOROTOLO")
            {
                //   var tskExec1 = tskExecList.OfType<Flexo>();
                //   var tskExec2 = tskExecList.OfType<ControlTableRoll>();

                tskExecList = tskExecList.OfType<FlatRoll>().Where(x => x.FoilStamping ?? false);
            }


            //Created for Editor Machines
            if (codTypeOfTask == "STAMPAETICHROTOLO_LIST")
            {
                var tskExec1 = tskExecList.OfType<Flexo>();
                var tskExec2 = tskExecList.OfType<ControlTableRoll>();
                var tskExec3 = tskExecList.OfType<FlatRoll>();

                tskExecList = tskExec1.Union<TaskExecutor>(tskExec2).Union(tskExec3);
            }



            if (codTypeOfTask == "FUSTELLATURA" || codTypeOfTask == "TAGLIO" ||
            codTypeOfTask == "PLASTIFICATURA" || codTypeOfTask == "VERNICIATURA")
            {
                tskExecList = tskExecList.OfType<TaskExecutor>().Where(x => x.CodTypeOfTask == codTypeOfTask);
            }

            if (codTypeOfTask == "INPIANO")
            {
                var tskExec1 = tskExecList.OfType<LithoSheet>();
                var tskExec2 = tskExecList.OfType<DigitalSheet>();
                var tskExec3 = tskExecList.OfType<TaskExecutor>().Where(x => x.CodTypeOfTask == "FUSTELLATURA");
                var tskExec4 = tskExecList.OfType<TaskExecutor>().Where(x => x.CodTypeOfTask == "TAGLIO");

                var tskExec5 = tskExec1.Union<TaskExecutor>(tskExec2).Union<TaskExecutor>(tskExec3).Union<TaskExecutor>(tskExec4);

                var tskExec6 = tskExecList.OfType<TaskExecutor>().Where(x => x.CodTypeOfTask == "PLASTIFICATURA");

                tskExecList = tskExec5.Union<TaskExecutor>(tskExec6);

            }
//.........这里部分代码省略.........
开发者ID:algola,项目名称:backup,代码行数:101,代码来源:TaskExecutorEx.cs

示例6: InitCostDetail

        public override void InitCostDetail(IQueryable<TaskExecutor> tskExec, IQueryable<Article> articles)
        {
            if (!justInited)
            {
                base.InitCostDetail(tskExec, articles);

                String codTypeOfTask = String.Empty;
                Console.WriteLine(ProductPart); //= TaskCost.ProductPartTask.ProductPart;
                codTypeOfTask = TaskCost.ProductPartTask.OptionTypeOfTask.CodTypeOfTask;
                tskExec = TaskExecutor.FilterByTask(tskExec, codTypeOfTask);
                TaskExecutors = tskExec.ToList();

                ICollection<ProductPartsPrintableArticle> productPartPrintabelArticles = new List<ProductPartsPrintableArticle>();
                productPartPrintabelArticles = TaskCost.ProductPartTask.ProductPart.ProductPartPrintableArticles;

                #region Format
                List<string> formats = new List<string>();
                var widthList = new List<Nullable<double>>();

                //
                //voglio sapere quali sono i formati degli articoli ma gli articoli che posso stampare dipendono dal tipo di macchina!!!!
                foreach (var item in productPartPrintabelArticles)
                {
                    widthList = articles.OfType<RollPrintableArticle>()
                               .Where(x => x.TypeOfMaterial == item.TypeOfMaterial &&
                                   x.Color == item.Color &&
                                   x.Adhesive == item.Adhesive &&
                                   x.Weight == item.Weight &&
                                   x.NameOfMaterial == item.NameOfMaterial)
                                       .Select(x => x.Width).ToList();
                }

                foreach (var width in widthList)
                {
                    if (BuyingWidths == null) BuyingWidths = new List<double>();
                    BuyingWidths.Add(width ?? 0);
                }

                #endregion
                
            }
        }
开发者ID:algola,项目名称:backup,代码行数:42,代码来源:PrintingRollCostDetail.cs

示例7: ApplyExpressions

        public IQueryable ApplyExpressions(IQueryable queryable)
        {
            if (queryable.ElementType != OfType.Type)
                queryable = queryable.OfType(OfType.Type);

            queryable = queryable.Where(FilterExpression);

            if (GroupByExpression == null)
            {
                // OrderBy is applied BEFORE select if GroupBy has not been specified.
                queryable = ApplyOrderByExpression(queryable);
            }
            else
                queryable = queryable.GroupBy(GroupByExpression);

            if (SelectExpression != null)
            {
                queryable = queryable.Select(SelectExpression);

                // OrderBy is applied AFTER select if GroupBy has been specified.
                if (GroupByExpression != null)
                    queryable = ApplyOrderByExpression(queryable);
            }
            else if (GroupByExpression != null)
            {
                throw new PomonaExpressionSyntaxException(
                    "Query error: $groupby has to be combined with a $select query parameter.");
            }

            return queryable;
        }
开发者ID:Pomona,项目名称:Pomona,代码行数:31,代码来源:PomonaQuery.cs


注:本文中的IQueryable.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。