我需要在RDLC报告中创建备用行颜色,该报告还考虑了组.
如果我使用表达式
=Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White")
Run Code Online (Sandbox Code Playgroud)
显然,这会在使用组时产生问题.我没有太多运气找到信息所以任何帮助都会很棒.
我有问题试图从一个接口NSubstitute
返回一个IEnumerable
接口Task
.
工厂我在嘲笑:
public interface IWebApiFactory<T> : IDisposable
{
<T> GetOne(int id);
Task<IEnumerable<T>> GetAll();
Task<IEnumerable<T>> GetMany();
void SetAuth(string token);
}
Run Code Online (Sandbox Code Playgroud)
测试方法:
[TestMethod]
public async Task TestMutlipleUsersAsViewResult()
{
var employees = new List<EmployeeDTO>()
{
new EmployeeDTO(),
new EmployeeDTO()
};
// Arrange
var factory = Substitute.For<IWebApiFactory<EmployeeDTO>>();
factory.GetMany().Returns(Task.FromResult(employees));
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
无法从'System.Threading.Tasks.Task>转换为System.Func >>
这是一个问题,我通过一个列表,IEnumerable
尽管List
是这样做IEnumerable
?
编辑:
这些是其中的功能 NSubstitute
public static ConfiguredCall Returns<T>(this T value, Func<CallInfo, T> returnThis, params Func<CallInfo, T>[] returnThese);
public static ConfiguredCall …
Run Code Online (Sandbox Code Playgroud) 我目前有一个非常简单的方法并计算一个CurveValue(自定义对象)列表,我遇到的问题是我需要计算参数并传回小数而不实际更改参数.
我尝试将AddRange()放入一个新对象中,这样参数曲线就不会受到影响,但似乎参考仍然存在,并且在执行ForEach()后曲线和曲线A都发生了变化.
我假设它仍然被引用,但有一个简单的方法来做这个而不通过参数曲线枚举并将其添加到curveA?
public decimal Multiply(List<CurveValue> curve, decimal dVal)
{
List<CurveValue> curveA = new List<CurveValue>();
curveA.AddRange(curve);
curveA.ForEach(a => a.Value = decimal.Round(a.Value, 4) * dVal);
return Sum(curveA);
}
public decimal Sum(List<CurveValue> curveA)
{
return curveA.Sum(x => x.Value);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下映射路由设置自定义路由
编辑:我的完整路线配置
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
#region FixtureAdmin
routes.MapRoute(
name: "FixtureEdit",
url: "{controller}/{action}/{id}",
defaults: new { controller = "FixtureAdmin", action = "Edit", id = UrlParameter.Optional }
);
#endregion
#region Results
routes.MapRoute(
name: "ResultAdd",
url: "{controller}/{action}/{fixtureId}",
defaults: new { controller = "Result", action = "Add", fixtureId = UrlParameter.Optional }
);
#endregion
Run Code Online (Sandbox Code Playgroud)
和我的控制器代码
public ActionResult Add(int fixtureId)
{
// return model to view etc..
}
Run Code Online (Sandbox Code Playgroud)
即使我已将参数指定为可选参数,也会出现异常. …
我正在尝试通过 jQuery Ajax 检索对象列表
我有一个这样的控制器方法:
[HttpGet]
public JsonResult GetAllStates(string listname = "")
{
clsDdl ddl = new clsDdl();
List<clsDdl> retval = new List<clsDdl>();
ddl.id = "1";
ddl.value = "Dropdown1";
ddl.status = "DDL Status";
ddl.attributes = "First Dropdown Text";
retval.Add(ddl);
//return retval;
return Json(new
{
list = retval
}, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
这是我试图返回的 Dropdown 类
public class clsDdl
{
public string id { get; set; }
public string value { get; set; }
public string status { get; set; }
public string …
Run Code Online (Sandbox Code Playgroud) 我想根据上周和上个月在c#中检索记录.对于上周我想要从星期日到星期六的记录.对于上个月我想要获得上个月的开始日期来获取所有记录,直到该月末.
我不应该在上周获取最近六天的记录,而是想从当前周(星期日)开始日期找到最后一个星期日.
我找到了找到上个月第一天和最后一天的解决方案---->
var first = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(-1);
var last = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddDays(-1);
Run Code Online (Sandbox Code Playgroud)
上周发现----->
DateTime _currDateTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified);
DateTime _currentDate;
DateTime _lastWeekStartDate;
_currentDate = _currDateTime.StartOfWeek(DayOfWeek.Sunday);
_lastWeekStartDate = _currentDate.AddDays(-1);
tempfromdate = _lastWeekStartDate.StartOfWeek(DayOfWeek.Sunday);
temptodate = tempfromdate.EndOfWeek(DayOfWeek.Saturday);
Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net-mvc ×3
.net ×1
ajax ×1
jquery ×1
linq ×1
nsubstitute ×1
rdlc ×1
report ×1
sum ×1
unit-testing ×1