« first day (4500 days earlier)      last day (454 days later) » 

 
2 hours later…
7:30 AM
Good moaning
 
 
2 hours later…
9:40 AM
 
uwe
 
 
3 hours later…
12:30 PM
yo, with the generic math IEqualityOperators<TSelf, TOther, TResult> interface, I get an "Operator '==' is ambiguous on operands of type 'TValue' and 'TValue'" when I say TValue : IEqualityOperators<TValue, TValue, bool> but somehow the code still compiles and runs
how can I get rid of the error or make sure there's no ambiguity?
 
12:42 PM
 
for the record, _vertices is a list of Vertex<TValue>
 
1:03 PM
var p = new Products
                    {
                        SysId = xe1.Attribute("Sys_Oid")?.Value,
                        Mainproduct = xe1.Name.ToString(),
                        Name = xe1.Attribute("Name")?.Value,
                        NameIcon = xe1.Attribute("DefaultIconName")?.Value,
                        Visible = xe1.Descendants("ProductVisibility").FirstOrDefault().Attribute("Visible")?.Value

                    };
Hi All, i'm getting error @ Visible = xe1.Descendants("ProductVisibility").FirstOrDefault().Attribute("Visible")?.Value
How can i verify with if null or not?
System.Linq.Enumerable.FirstOrDefault<TSource>(...) returned null
 
Maybe this way, idk: Visible = xe1.Descendants("ProductVisibility").FirstOrDefault() == null ? false : Visible = xe1.Descendants("ProductVisibility").FirstOrDefault().Attribute("Visible") == null ? false : Visible = xe1.Descendants("ProductVisibility").FirstOrDefault().Attribute("Visible").Value
 
@user838691 it's because xe1.Descendants("ProductVisibility") is null, if you separate that part out you can null check for it
I'd also suggest separating all the navigations for readability before making the new product
 
@Darj thanks,; cannot omplicitly convert type string to bool
@JansthcirlU Yes some nodes doest have so it throws null
 
What's the type of Products.Visible property? bool?
 
if it's okay that some of the things return null, then the simplest fix is to change it to Visible = xe1.Descendants("ProductVisibility")?.FirstOrDefault()?.Attribute("Visible")?.Value but that's pretty icky
 
1:14 PM
@Darj it return true, false but i'm reading it as string
 
basically put a question mark after everything that can be null and then the whole expression will return null if one of the members is null
and since you're trying to assign a potentially null value to a boolean, you'll have to make a decision
 
@JansthcirlU oh good point
 
either make the 'Visible' property a nullable boolean or use the '??' operator to change the default behaviour to 'false' if the whole expression returns null
e.g.

bool? nullableBool = null; // valid
bool normalBool = nullableBool; // invalid
bool normalBool2 = nullableBool ?? false; // valid
 
@JansthcirlU this works, no error thanks also his comment seems valid @JansthcirlU
@JansthcirlU ok thanks. How can we rewrite this (@Darj code) : Visible = xe1.Descendants("ProductVisibility")?.FirstOrDefault()?.Attribute("Visible")?.Value
 
write '?? false' after the whole expression
 
1:21 PM
@JansthcirlU Invalid expression term,
 
what version of .NET are you using?
 
@JansthcirlU 4.7.2
 
I'd just put that whole expression into a variable 'visible' then, and inside new product do Visible = visible != null ? (bool)visible : false or whatever you want the default to be
 
@JansthcirlU can i see the code? thanks
 
var visible = xe1...
 
@JansthcirlU thanks
@Darj thanks so much
 
[Darj] You're welcome
 
ANother question, how can we convert list inside a list (nested list) to a datatable?
 
try stackoverflow
 
public class Products
	{
		public string SysId { get; set; }
		public string Mainproduct { get; set; }
		public string Name { get; set; }
		public string Visible { get; set; }
		public string From { get; set; }
		public List<PriceDetail> Prices { get; set; } = new List<PriceDetail>();
		public string NameIcon { get; set; }
	}
i can covert to datable without List<price detail> but with price detail i'm not getting the each collection value
@JansthcirlU ok do that..
 
1:42 PM
[Captain Obvious] ew datatable
 
2:21 PM
Hi Guys quick question about binding a form to a model. In the past I use id in the for to bind but I wanted to see if there is a different way
@Html.RadioButtonFor(m => m.selectedType[idx].RequestType, "Copies", new { @id = "requestyypeCopiesId", @style = "margin:2px 2px;" })
The problem with this is validation message is displaying selectedType[0].RequestType
 
3:07 PM
[Captain Obvious] what the hell is that
 
@Botler I guess code ;)
 
[Captain Obvious] Looks Like Code ✔️
 
3:28 PM
How do you guys build a dynamic form that will bind to a model
 
3:40 PM
<ul data-required-msg="Question is Required" data-role="radiogroup" id="PollingResponses_3__Value" name="PollingResponses[3].Value" title="LabourCost is requried" validationmessage="Select movie" class="k-radio-list k-list-vertical" role="radiogroup">
<li class="k-radio-item" role="none"><input type="radio" class="k-radio k-invalid" value="1411" name="PollingResponses[3].Value" id="b4767c9b-4910-413f-a651-d96f2bd328f1" required="required" aria-invalid="true" aria-describedby="PollingResponses[3].Value_validationMessage"><label class="k-radio-label" for="b4767c9b-4910-413f-a651-d96f2bd328f1">Yes</label></li></ul>
<span class="k-form-error k-invalid-msg field-validation-error" data-for="PollingResponses[3].Value" id="PollingResponses[3].Value_validationMessage" data-valmsg-for="PollingResponses[3].Value">PollingResponses[3].Value is required</span>
this span is using the name as the HTML message
 

« first day (4500 days earlier)      last day (454 days later) »