Exemplo n.º 1
0
 public object[] GetStretcher(ProductColorTable colorTable)
 {
     if (colorTable == null)
     {
         return(null);
     }
     Dictionary <T, byte>[] map = new Dictionary <T, byte>[3]
     {
         new Dictionary <T, byte>(),
         new Dictionary <T, byte>(),
         new Dictionary <T, byte>()
     };
     GetMap(map, colorTable);
     Func <T, byte>[] sts = new Func <T, byte>[]
     {
         GetStretcherFunc(map[0], colorTable),
         GetStretcherFunc(map[1], colorTable),
         GetStretcherFunc(map[2], colorTable)
     };
     return(sts.ToArray().Cast <object>().ToArray());
 }
        //public IActionResult Index()
        //{
        //    return View(_context.Employees.AsNoTracking());
        //}

        //public IActionResult Index(string searchTerm)
        //{
        //    IQueryable<Employee> data = _context.Employees;
        //    if (!string.IsNullOrEmpty(searchTerm))
        //    {
        //        data = data.Where(e => EF.Functions.Like(e.FirstName, searchTerm));
        //    }
        //    return View(data);
        //}


        //public async Task<IActionResult> Index(string searchTerm)
        //{
        //    IQueryable<Employee> employees = _context.Employees;
        //    if (!string.IsNullOrEmpty(searchTerm))
        //    {
        //        employees = employees.Where(e => EF.Functions.Like(e.FirstName, searchTerm));
        //    }
        //    HttpClient client = new HttpClient();
        //    ViewBag.PageSize = (await client.GetAsync("http://apress.com")).Content.Headers.ContentLength;
        //    return View(await employees.ToListAsync());
        //}

        //public IActionResult Index(string searchTerm)
        //{
        //    return View(string.IsNullOrEmpty(searchTerm) ? _context.Employees : query(_context, searchTerm));
        //}

        //public IActionResult Index(decimal salary = 0)
        public IActionResult Index(string searchTerm)
        {
            //ViewBag.Secondaries = _context.Set<SecondaryIdentity>();
            //return View(_context.Employees.Include(e => e.OtherIdentity).OrderByDescending(e => EF.Property<DateTime>(e, "LastUpdated")));
            //IEnumerable<Employee> data = _context.Employees.Include(e => e.OtherIdentity).OrderByDescending(e => e.LastUpdated).ToArray();
            //ViewBag.Secondaries = data.Select(e => e.OtherIdentity);

            //Raw Sql ve EF birleşimi
            //IEnumerable<Employee> data = _context.Employees
            //    .FromSql($@"
            //    select
            //        *
            //    from
            //        Employees
            //    where
            //        SoftDeleted = 0 and
            //        Salary>{salary}")
            //        .Include(e => e.OtherIdentity)
            //        .OrderByDescending(e => e.Salary)
            //        .OrderByDescending(e => e.LastUpdated).ToArray();
            //ViewBag.Secondaries = data.Select(e => e.OtherIdentity);


            //Stored procedure
            //IEnumerable<Employee> data = _context.Employees // Running stored procedure
            //    .FromSql($@"
            //    execute GetBySalary @SalaryFilter = {salary}")
            //    .IgnoreQueryFilters();


            //View
            //IEnumerable<Employee> data = _context.Employees
            //.FromSql($@"SELECT * from NotDeletedView
            //WHERE Salary > {salary}")
            //.Include(e => e.OtherIdentity)
            //.OrderByDescending(e => e.Salary)
            //.OrderByDescending(e => e.LastUpdated)
            //.IgnoreQueryFilters()
            //.ToArray();
            //ViewBag.Secondaries = data.Select(e => e.OtherIdentity);


            //Function
            //IEnumerable<Employee> data = _context.Employees
            //.FromSql($@"SELECT * from GetSalaryTable({salary})")
            //.Include(e => e.OtherIdentity)
            //.OrderByDescending(e => e.LastUpdated)
            //.IgnoreQueryFilters()
            //.ToArray();
            //ViewBag.Secondaries = data.Select(e => e.OtherIdentity);



            //IEnumerable<Employee> data = _context.Employees
            //.Include(e => e.OtherIdentity)
            //.OrderByDescending(e => e.LastUpdated)
            //.IgnoreQueryFilters()
            //.ToArray();
            //ViewBag.Secondaries = data.Select(e => e.OtherIdentity);

            IQueryable <Employee> query = _context.Employees.Include(e => e.OtherIdentity);

            if (!string.IsNullOrEmpty(searchTerm))
            {
                //query = query.Where(e => EF.Functions.Like($"{e.FirstName[0]}{e.FamilyName}", searchTerm));
                query = query.Where(e => EF.Functions.Like(e.GeneratedValue, searchTerm));
            }
            IEnumerable <Employee> data = query.ToArray();

            ViewBag.Secondaries = data.Select(e => e.OtherIdentity);
            return(View(data));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Index(string searchTerm, decimal salary = 0)
        {
            //IQueryable<Employee> data = context.Employees;
            //if (!string.IsNullOrEmpty(searchTerm))
            //{
            //    data = data.Where(e => EF.Functions.Like(e.FirstName, searchTerm));
            //}
            //HttpClient client = new HttpClient();
            //ViewBag.PageSize = (await client.GetAsync("http://apress.com"))
            //    .Content.Headers.ContentLength;

            //return View(
            //    string.IsNullOrEmpty(searchTerm)
            //        ? await context.Employees.ToListAsync()
            //        : query(context, searchTerm)
            //);
            //IEnumerable<Employee> data = context.Employees
            //    .Include(e => e.OtherIdentity)
            //    .OrderByDescending(e => e.LastUpdated)
            //    .ToArray();
            //IEnumerable<Employee> data = context.Employees
            //    .FromSql($@"SELECT * FROM
            //               Employees
            //               WHERE SoftDeleted = 0 AND Salary > {salary}
            //               ")
            //     .Include(e => e.OtherIdentity)
            //     .OrderByDescending(e => e.Salary)
            //     .OrderByDescending(e => e.LastUpdated).ToArray();

            ////ViewBag.Secondaries = context.Set<SecondaryIdentity>();
            //ViewBag.Secondaries = data.Select(e => e.OtherIdentity);

            //IEnumerable<Employee> data = context.Employees
            //    .FromSql($"Execute GetBySalary @SalaryFilter={salary}")
            //    .IgnoreQueryFilters();

            //IEnumerable<Employee> data = context.Employees
            //    .FromSql($@"SELECT * FROM NotDeletedView
            //                WHERE Salary > {salary}")
            //    .Include(e => e.OtherIdentity)
            //    .OrderByDescending(e => e.Salary)
            //    .OrderByDescending(e => e.LastUpdated)
            //    .IgnoreQueryFilters()
            //    .ToArray();
            IQueryable <Employee> query = context.Employees.Include(e => e.OtherIdentity);

            if (!string.IsNullOrEmpty(searchTerm))
            {
                query = query.Where(e => EF.Functions.Like(e.GenratedValue, searchTerm));
            }
            IEnumerable <Employee> data = query.ToArray();

            //IEnumerable<Employee> data = context.Employees
            //    //.FromSql($@"SELECT * from GetSalaryTable({salary})")
            //    .Include(e => e.OtherIdentity)
            //    //.OrderByDescending(e => e.Salary)
            //    .OrderByDescending(e => e.LastUpdated)
            //    .IgnoreQueryFilters()
            //    .ToArray();

            ViewBag.Secondaries = data.Select(e => e.OtherIdentity);

            return(View(data));
        }
Exemplo n.º 4
0
 private ColorPicking(Func<Tuple<int,int>, byte>[] functions, string name,int _size=SPDAssets.MAX)
 {
     _functions = functions.ToArray();
     _s = name;
     size = _size;
 }