zoukankan      html  css  js  c++  java
  • 抽时间回答一下

    http://www.cnblogs.com/leotsai/p/aspnet-tests-for-juniors.html

    第4题 只是考会不会扩展方法

    public static IQueryable<T> WhereNotDeleted<T>(this IQueryable<T> query) where T : Product
    {
    return query.Where(t => t.IsDeleted == "No");
    }

    public static IQueryable<Product> WhereNotDeleted(this IQueryable<Product> query) 
    {
    return query.Where(t => t.IsDeleted == "No");
    }


    第5题 2表关联group by 

    SELECT a.`Name` NAME,b.`Year` YEAR,b.`Month` MONTH,SUM(b.`Amount`) Icome FROM USER a,Income b WHERE a.`ID`=b.`UserId`
    GROUP BY a.`Name`,b.`Year`,b.`Month`
    ORDER BY a.`Name`,b.`Year`,b.`Month`


    第6题 考linq的2表关联Group By 

                var rtSource = from a in users
                               from b in incomes
                               where a.Id == b.UserId
                               group new { a, b } by new { a.Name, b.Year, b.Month } into g
                               select new UserIncomeDto() { Name=g.Key.Name,Year=g.Key.Year,Month=g.Key.Month,Income=g.Sum(t=>t.b.Amount)};
                return rtSource.ToList();


    第7题 mvc内容目前没有接触到
    第8题用 Func<Product, string> 来做的吧??

    class Product1
        {
            public string Name { get; set; }
            public string Description { get; set; }
    
            public void Validate1()
            {
                if (string.IsNullOrEmpty(this.Name))
                {
                    throw new Exception("please enter a name for the product");
                }
                if (string.IsNullOrEmpty(this.Description))
                {
                    throw new Exception("product description is required");
                }
            }
    
            public void Validate2()
            {

                 //this.Require(x => x.Name, "please enter a name for the product");
                 //this.Require(x => x.Description, "product description is required");

    this.Require(GetName, "please enter a name for the product");
                this.Require(x => { string baba = x.Description + "bbbbb"; return baba; }, "product description is required");
            }
    
            string GetName(Product1 haha)
            {
                return haha.Name;
            }
    
            void Require(Func<Product1, string> aaa, string erro)
            {
                if ((aaa(this) + "").Length == 0)
                    Console.WriteLine(erro);
                else
                    Console.WriteLine(aaa(this));
            }
        }
  • 相关阅读:
    使用python3安装frida-tools出错
    xposed代码示例
    android studio3.4打jar包
    uiautomator代码例子--java
    Mac下不能成功打开uiautomatorviewer的问题解决
    mac下生成keystore
    Python杨辉三角算法
    Python迭代器:捕获Generator的返回值
    Python函数:一个简单的迭代
    Python参数组合
  • 原文地址:https://www.cnblogs.com/m7777/p/4109636.html
Copyright © 2011-2022 走看看