我有一个从xml文档返回的事件ID列表,如下所示
public IEnumerable<EventFeed> GetEventIdsByEventDate(DateTime eventDate)
{
return (from feed in xmlDoc.Descendants("Show")
from ev in feed.Elements("Event")
where Convert.ToDateTime(ev.Attribute("Date").Value).ToShortDateString() == eventDate.ToShortDateString()
select new EventFeed()
{
EventShowCode = feed.Attribute("Code").Value
}).ToList();
}
Run Code Online (Sandbox Code Playgroud)
我现在需要查询我的数据库以匹配等于从上述方法返回的eventIds的事件.所以我会有类似的东西:
select*from eventsdb其中getEventIdsByEventDate()中的eventId
我怎么能用LINQ做到这一点
我似乎无法得到任何答案.
这是从XML提要中查找eventIds的方法
public IList<EventsDetails> GetEventIds(DateTime eventDate)
{
var eventids = (from feed in xmlDoc.Descendants("Show")
from ev in feed.Elements("Event")
where Convert.ToDateTime(ev.Attribute("Date").Value).ToShortDateString() == eventDate.ToShortDateString()
select new EventsDetails()
{
EventId = feed.Attribute("Code").Value
}).ToList();
return eventids;
}
Run Code Online (Sandbox Code Playgroud)
这是查找数据库中事件的方法
public IEnumerable<EventFeed> GetAllEventsFromDatabase()
{
var allEvents = from eventsList in GetEventsList()
select new EventFeed() …Run Code Online (Sandbox Code Playgroud) 我有一个事件ID列表,我想从我的select语句中排除,但不知道如何实现这个:
这是存储我的事件ID列表的内容
List<int> ExcludedEvents;
Run Code Online (Sandbox Code Playgroud)
这是我的select语句(来自XML提要)
var allEvents = from eventsList in xmlDoc.Elements("shows").Elements("Show")
select new EventFeed()
{
EventName = eventsList.Attribute("Name").Value,
EventSummary = eventsList.Attribute("ShortDesc").Value,
EventDetails = eventsList.Attribute("LongDesc").Value,
EventShowCode = eventsList.Attribute("Code").Value
};
Run Code Online (Sandbox Code Playgroud)
我想选择所有事件,除了eventId匹配EventShowCode值的事件
我查看了except运算符,但不确定如何实现它
从这个页面(http://developer.apple.com/programs/ios/distribute.html)我读过这个
自定义B2B应用
您还可以直接向拥有批量购买计划帐户的企业客户提供自定义B2B应用程序.自定义B2B应用程序提供独特的定制解决方案,以满足特定的业务需求或要求.
有没有人有这方面的更多细节?我有一个专门针对个别公司的应用创意,比如说我正在为ABC公司构建一个应用程序,这个应用程序仅用于公司ABC而且没有其他人,我如何分发这样的应用程序(到公司ABC)&can我按月订阅此应用程序?
谢谢kb
使用LINQ to XML,这是我的XML示例
<shows>
<Show Code="456" Name="My Event Name">
<Event Code="2453" VenueCode="39" Date="2010-04-13 10:30:00" />
<Event Code="2454" VenueCode="39" Date="2010-04-13 13:30:00" />
<Event Code="2455" VenueCode="39" Date="2010-04-14 10:30:00" />
<Event Code="2456" VenueCode="39" Date="2010-04-14 13:30:00" />
<Event Code="2457" VenueCode="39" Date="2010-04-15 10:30:00" />
</Show>
<Show... />
<Show... />
</shows>
Run Code Online (Sandbox Code Playgroud)
如何返回特定节目的日期列表?我在查询字符串中传递显示代码("456"),并希望将所有日期/时间作为列表返回.
这是我到目前为止的代码:
XDocument xDoc = XDocument.Load("path to xml");
var feeds = from feed in xDoc.Descendants("Show")
where feed.Attribute("Code").Equals("456")
select new
{
EventDate = feed.Attribute("Date").Value
};
foreach(var feed in feeds)
{
Response.Write(feed.EventDate + "<br />");
}
Run Code Online (Sandbox Code Playgroud)
但我没有得到任何结果
我想向今天过生日的所有用户发送一封电子邮件
我使用内置的asp.net(3.5)会员资格.所有用户都有一个配置文件(存储在aspnet_Profile中),其中包含一个名为"birthday"的日期/时间属性.我需要从今天用户生日的'aspnet_Membership'表中获取用户电子邮件地址列表,以及aspnet_Profile表中字符串属性的用户'firstname'.
我希望使用C#LINQ返回一个列表.
我不知道如何访问配置文件表中的birthday属性,具体取决于它在db表中的存储方式,即名称/值列
使用最新版本的Wordpress和Woocommerce。
如果我的商店中有2页产品,并且在我的分页链接中单击PAGE 1,那么我将获得301重定向,该重定向到/ shop。
出于SEO的目的,我想禁用301重定向并保持链接在分页链接中,即/ shop / page / 1
这似乎是Woocommerce中的默认行为,而且不是我的Shopkeeper主题正在执行的操作。
我有以下格式的活动日期列表
13/04/2010 10:30:00
13/04/2010 13:30:00
14/04/2010 10:30:00
14/04/2010 13:30:00
15/04/2010 10:30:00
15/04/2010 13:30:00
16/04/2010 10:30:00
17/04/2010 11:00:00
17/04/2010 13:30:00
17/04/2010 15:30:00
Run Code Online (Sandbox Code Playgroud)
如何输出列表,以便日期只显示一次,然后显示该日期的时间,因此上面的列表看起来像这样:
13/04/2010
10:30:00
13:30:00
14/04/2010
10:30:00
13:30:00
15/04/2010
10:30:00
13:30:00
16/04/2010
10:30:00
17/04/2010
11:00:00
13:30:00
15:30:00
Run Code Online (Sandbox Code Playgroud) 我一直在看这个代码来创建一个基本的购物车,但缺点是它使用静态方法,因此购物车项目(当添加到购物篮时)在会话中共享.有人可以指出如何修改ShoppingCart方法来删除此限制?
但我确定这是违法的代码
// Readonly properties can only be set in initialization or in a constructor
public static readonly ShoppingCart Instance;
// The static constructor is called as soon as the class is loaded into memory
static ShoppingCart() {
// If the cart is not in the session, create one and put it there
// Otherwise, get it from the session
if (HttpContext.Current.Session["ASPNETShoppingCart"] == null) {
Instance = new ShoppingCart();
Instance.Items = new List<CartItem>();
HttpContext.Current.Session["ASPNETShoppingCart"] = Instance;
} else { …Run Code Online (Sandbox Code Playgroud) c# ×3
linq ×3
asp.net ×1
cart ×1
datetime ×1
distribution ×1
except ×1
iphone ×1
membership ×1
profile ×1
shopping ×1
woocommerce ×1
wordpress ×1
xml ×1