Linq to Entities查询获取条件数据。 [英] Linq to Entities query to get conditional data.

查看:55
本文介绍了Linq to Entities查询获取条件数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,


我正在使用带有Entity Framework的ASP.Net MVC开发一个应用程序。我有以下表格:


养老金领取者(Id,姓名)


DATA:(1,John),(2,Mathew),( 3,Jacky)


结构(Id,PensionerId,日期,基本,医疗)


DATA:(1,1:01/10/2016 ,1000,500),(2,1,01 / 04 / 2017,1200,500),(3,2,01/10 / 2016,1500,500),(4,3,01/10 / 2016,2000,2000) ,500) 


津贴(Id,Qtr,年份,费率)


DATA:(1,III,2016,22%), (2,我,2017年,25%),(3,II,2017年,28%),(4,III,2017年,30%)


我需要按月生成付款根据用户的标准。


例如,如果 用户选择2017年的月:04,付款应如下所示生成:


名称       金额


John          2000     公式:1200(基本截至2017年4月1日)* 25%(2017年第一季度适用津贴)+ 500(医疗)


Mathew      2375     公式:1500(基本截至2016年10月1日)* 25%(2017年第1季度的适用限额)+ 500(医疗)


Jacky          3000     公式:2000(基本截至2016年10月1日)* 25%(2017年第1季度的适用限额)+ 500(医疗)


上面的公式解释了计算部分,不会显示在结果中。)


同样,当用户选择月份:10表示2016年金额应根据给定期间的适用结构和津贴计算。


请建议LINQ查询以实现上述结果。


问候,


Arun。


 


解决方案

我建议您学习如何使用DTO模式。


https://www.codeproject.com/Articles/1050468/Data-Transfer-Object-Design-Pattern-in-Csharp


我建议您学习如何使用Linq投影。


http://csharp-station.com/Tutorial/Linq/Lesson02



Sir,

I am developing an application using ASP.Net MVC with Entity Framework. I have the following tables:

Pensioner(Id, Name,)

DATA: (1, John), (2, Mathew), (3, Jacky)

Structure(Id, PensionerId, Date, Basic, Medical)

DATA: (1, 1, 01/10/2016, 1000, 500), (2, 1, 01/04/2017, 1200, 500), (3, 2, 01/10/2016, 1500, 500), (4, 3, 01/10/2016, 2000, 500) 

Allowance(Id, Qtr, Year, Rate)

DATA: (1, III, 2016, 22%), (2, I, 2017, 25%), (3, II, 2017, 28%), (4, III, 2017, 30%)

I need to generate monthly payment as per the user's criteria.

For instance, if the user selects Month: 04 for the year 2017, the payment should generate as shown below:

Name        Amount

John          2000      Formula: 1200(basic as on 01/04/2017) * 25% (Applicable allowance for Ist qtr of 2017)+ 500(Medical)

Mathew      2375      Formula: 1500(basic as on 01/10/2016) * 25% (Applicable allowance for 1st qtr of 2017) + 500(Medical)

Jacky         3000      Formula: 2000(basic as on 01/10/2016) * 25%(Applicable allowance for 1st qtr of 2017) + 500(Medical)

(The Formula above explains calculation part and not to be displayed in the result.)

Similarly, when the user selects Month: 10 for the year 2016 the Amount should get calculated taking applicable Structure and allowance for the given period.

Please suggest a LINQ query to achieve the result as described above.

Regards,

Arun.

 

解决方案

I suggest that you learn how to use the DTO pattern.

https://www.codeproject.com/Articles/1050468/Data-Transfer-Object-Design-Pattern-in-Csharp

I suggest that you learn how to use Linq projections.

http://csharp-station.com/Tutorial/Linq/Lesson02


这篇关于Linq to Entities查询获取条件数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆