public static string AsParmBooleanCheck(this IPrimaryKeyProperties This, string varPrefix, string op) { var ret = ""; for (int i = 0; i < This.Count; i++) { var property = This[i]; ret += (i > 0 ? @" && " : @"") + property.Alias + " " + op.Trim() + " " + varPrefix + "." + property.AsObjectPropertyName(); } return(ret); }
/// <summary> /// Useful for rendering the primary keys for a comma delimited parameter list /// Will return the primary keys in the following format /// [0]Parm1 (number), Parm2(text), Parm3 (number) /// will return /// int Parm1, string Parm2, int Parm3 /// </summary> /// <param name="delimiter">Defaults to ","</param> /// <param name="elementSet">Defaults to " "</param> /// <returns></returns> internal static string AsParmString(this IPrimaryKeyProperties This, string prefix, string delimiter, string elementSet) { var ret = ""; for (int i = 0; i < This.Count; i++) { var property = This[i]; ret += (i > 0 ? delimiter + @" " : @" ") + prefix + property.Type.ToNetType(true) + elementSet + property.Alias.ToSingular(); } return(ret); }
/// <summary> /// Useful for rendering the primary keys for a FindAsync /// Will return the primary keys in the following format /// [0]Parm1 (number), Parm2(text), Parm3 (number) /// will return /// Parm1, Parm2, Parm3 /// </summary> /// <param name="varPrefix">What the variable will be prefixed with.</param> /// <param name="AsObjectPropertyName">Use the object property name as opposed to alias.</param> public static string AsCsvString(this IPrimaryKeyProperties This, string varPrefix, bool AsObjectPropertyName) { var ret = ""; for (int i = 0; i < This.Count; i++) { var property = This[i]; ret += (i > 0 ? @", " : @" ") + ((varPrefix.Length > 0) ? varPrefix + "." : "") + ((AsObjectPropertyName) ? property.AsObjectPropertyName() : property.Alias); } return(ret); }
/// <summary> /// Useful for rendering the primary keys for a linq search query /// Will return the primary keys in the following format /// [0]Parm1 (number), Parm2(text), Parm3 (number) /// will return /// t.Parm1 == Parm1 and t.Parm2 == Parm2 and t.Parm3 == Parm3 /// </summary> /// <param name="prefix">Defaults to "t"</param> /// <param name="delimiter">Defaults to " and "</param> /// <param name="elementSet">Defaults to " == "</param> /// <param name="prefixSetter">Defaults to ""</param> /// <returns></returns> internal static string AsLinqEquationString(this IPrimaryKeyProperties This, string prefix, string delimiter, string elementSet, string prefixSetter) { // t.@_Model[key].PrimaryKeys[0].Name == @key.ToSingular() var ret = ""; for (int i = 0; i < This.Count; i++) { var property = This[i]; var entityName = property.Parent.Name; ret += (i > 0 ? delimiter + @" " : @" ") + prefix + (prefix.Length > 0 ? "." : "") + property.AsObjectPropertyName() + elementSet + prefixSetter + (prefixSetter.Length > 0 ? "." : "") + property.Alias.ToSingular(); } return(ret); }
/// <summary> /// This will return the primary keys a an OData Route String /// </summary> /// <returns>The primary keys <see langword="async"/> an oid.</returns> /// <param name="This">This.</param> public static string AsODataRouteString(this IPrimaryKeyProperties This) { var ret = ""; if (This.Count == 0) { return(""); } //To keep previous functionality, if there is only 1 key, it will only render the single parm name else if (This.Count == 1) { var property = This[0]; ret = "{" + property.Alias + "}"; } else { for (int i = 0; i < This.Count; i++) { var property = This[i]; ret += (i > 0 ? @", " : @" ") + property.Alias + "={" + property.Alias + "}"; } } return("(" + ret + ")"); }
/// <summary> /// Useful for rendering the primary keys for a linq search query /// Will return the primary keys in the following format /// [0]Parm1 (number), Parm2(text), Parm3 (number) /// will return /// t.Parm1 == Parm1 and t.Parm2 == Parm2 and t.Parm3 == Parm3 /// </summary> /// <returns>t.Parm1 == Parm1 and t.Parm2 == Parm2 and t.Parm3 == Parm3</returns> public static string AsLinqEquationString(this IPrimaryKeyProperties This) { return(This.AsLinqEquationString("t", " &&", "==", "")); }
/// <summary> /// Useful for rendering the primary keys for a comma delimited parameter list /// Will return the primary keys in the following format /// [0]Parm1 (number), Parm2(text), Parm3 (number) /// will return /// int Parm1, string Parm2, int Parm3 /// </summary> internal static string AsParmString(this IPrimaryKeyProperties This) { return(This.AsParmString("[FromODataUri] ", ",", " ")); }