如果同一表匹配的2列上的值
我想获得datacorrespondeid
如果mesobjetivo上的值
列在currentMonth
上是相同的,并且anoobjetivo 列在
语句根据extryear
上是相同的(列在同一表objetivoes
)。我想要这个,这样我就可以根据datacorrespondeid
找到语句。是否找到ID。
DateTime now = DateTime.Now;
string currentMonth = DateTime.Now.Month.ToString();
string currentYear = DateTime.Now.Year.ToString();
var datacorrespondeId = bd.Objetivoes.FirstOrDefault(m => m.MesObjetivo == int.Parse(currentMonth) || m.AnoObjetivo == int.Parse(currentYear));
using (Volta12BaseDEntities bd = new Volta12BaseDEntities())
{
if (datacorrespondeId != null)
{
string valorobjetivo = bd.Objetivoes.Where(m => datacorrespondeId.Equals(m.ValorObjetivo)).ToString();
var Objetivo = new List<Objetivo>()
{
new Objetivo{ValorObjetivo = int.Parse(valorobjetivo), MesObjetivo = int.Parse(currentMonth), AnoObjetivo = int.Parse(currentYear)},
};
};
};
I want to get the datacorrespondeID
if the value on MesObjetivo
column is the same on currentMonth
, and the value on AnoObjetivo
column is the same on currentYear
(the columns are on the same table Objetivoes
). I want this so I can follow to a If
statement according to if datacorrespondeId
finds an id or not.
DateTime now = DateTime.Now;
string currentMonth = DateTime.Now.Month.ToString();
string currentYear = DateTime.Now.Year.ToString();
var datacorrespondeId = bd.Objetivoes.FirstOrDefault(m => m.MesObjetivo == int.Parse(currentMonth) || m.AnoObjetivo == int.Parse(currentYear));
using (Volta12BaseDEntities bd = new Volta12BaseDEntities())
{
if (datacorrespondeId != null)
{
string valorobjetivo = bd.Objetivoes.Where(m => datacorrespondeId.Equals(m.ValorObjetivo)).ToString();
var Objetivo = new List<Objetivo>()
{
new Objetivo{ValorObjetivo = int.Parse(valorobjetivo), MesObjetivo = int.Parse(currentMonth), AnoObjetivo = int.Parse(currentYear)},
};
};
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论