Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ Query problem. Need to check if exists
    primarykey
    data
    text
    <p>I have 3 fields: <code>urlName</code>, <code>displayName</code> and <code>active</code>. This is check for edit record. What I want to do here is to check <code>UrlName</code> is unique in Db, but at the same time, if user has already saved the Url but changed <code>DisplayName</code> and <code>Active</code> then the record should update.</p> <p>Any one tell me how to solve that.</p> <pre><code>public bool NothingExceptUrlNameExists(string urlName, string displayName, bool active) { return (from p in _db.SubMenus where p.UrlName == urlName &amp;&amp; (p.DisplayName != displayName || p.DisplayName == displayName) &amp;&amp; (p.Active != active || p.Active == active) select p).Any(); } </code></pre> <p>updating record like </p> <pre><code> TryUpdateModel(existingMenu); _menu.Add(); </code></pre> <p><strong>This is what I want to achieve</strong></p> <p>My other 2 values should be added in Query DisplayName and Active. Suppose "Contact" UrlName already in DB. I am loading values from dropdown returning UrlName="About", DisplayName="About Us", Active = true. Now editing record. Here are the condition to match. </p> <p>1 - UrlName="About", DisplayName="About Test", Active = true --> This should update. </p> <p>2 - UrlName="About", DisplayName="About Us", Active = false --> This should update.</p> <p>3 - UrlName="About", DisplayName="About Test", Active = false --> This should update. </p> <p>Important : 4 - UrlName="newnotexist", DisplayName="About test", Active = false --> <strong>This should update UrlName and rest if changed.</strong> </p> <p>5 - UrlName="Contact", DisplayName="About Test", Active = false --> <strong>This should not update and generate error.</strong> </p> <p>I hope you understand what I want to do.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload