我有2个表 - Book和Ticket(id,borrowingDate,landingDate,idBook) - 我需要一种方法,使用我的DateTime属性验证一本书是否可用;如果borrowingDate为null - >可用的书 有我的模型类: 书:
<style>
/** DASHBOARD CONTAINER **/
.dashboard-container { border-right: solid 1px #000; margin-top: 5px; margin-bottom: 5px; overflow-x: scroll; white-space: nowrap; width: 100%; }
.dashboard-container .widget { clear: both; display: inline-block; vertical-align: top; }
/** FORM CONTAINER **/
.form-container { border: 1px solid #ccc; border-radius: 3px; height: 500px; margin-bottom: 5px; padding: 5px; width: 500px; }
/** BLADE CONTAINER **/
.blade-container .blade { border: 1px solid #ccc; border-radius: 3px; display: inline-block; height: 506px; margin-right: 2px; padding: 2px; width: 200px; }
</style>
票证:
<script id="tmplBlade" type="text/template">
<div class="blade">
Blade
</div>
</script>
<div class="dashboard-container">
<div class="widget">
<div class="form-container">
Form Controls go here
<input id="btnAppend" type="button" value="Append Blade" />
</div>
</div>
<div class="widget">
<div class="blade-container">
</div>
</div>
</div>
答案 0 :(得分:0)
这有帮助吗?
var availableBooks = books.Where(b =&gt; b.Tickets.Where(t =&gt; t.BorrowingDate == null).Count()== 0)。ToList();
这假定BorrowingDate可以为空(在您的模型中不是这种情况)。如果不是,你将不得不与“DateTime.MinValue”而不是null
进行比较