Search Results for

    Show / Hide Table of Contents

    Class SQLWrapper

    Inheritance
    object
    BaseEntity
    BaseEntityWithPermissions
    SQLWrapper
    Implements
    ISQLWrapper
    IBaseEntityWithPermissions
    ISetCopier
    IHasVersion
    IUserSpecific
    IHasFolderStructure
    IBaseEntity
    IEquatable<IBaseEntity>
    INotifyPropertyChanged
    INotifyPropertyChanging
    ICloneableAsync
    ICanTrackProperties
    ICloneableAsync<ISQLWrapper>
    IUserSpecificPublicToggle
    ISetItemLoaderOverride
    ISetCopierCloneAlterer
    Inherited Members
    BaseEntityWithPermissions.IsLocked(object)
    BaseEntityWithPermissions.CanWriteItem(object, IEntityRetriever, IReadOnlyCache, Guid)
    BaseEntityWithPermissions.PreLoadPermissions<T>(IEnumerable<T>, IEntityRetriever, IReadOnlyCache, Guid)
    BaseEntityWithPermissions.CanDeleteItem(object, IEntityRetriever, IReadOnlyCache, Guid)
    BaseEntityWithPermissions.CanChangeItemPermissions(object, IEntityRetriever, IReadOnlyCache, Guid)
    BaseEntity.HISTORY_ENDROWUPDATE_COLNAME
    BaseEntity.HasTrackedPropertyChanged(string)
    BaseEntity.OriginalTrackedPropertyValue(string)
    BaseEntity.OriginalTrackedPropertyValue<T>(string)
    BaseEntity.ClearTrackedOriginalValues()
    BaseEntity.GetAllOriginalTrackedPropertyValues()
    BaseEntity.GetLabel(string)
    BaseEntity.SetLabel(string, string)
    BaseEntity.SetSilentLabel(string, string)
    BaseEntity.ResetChangedTrackedPropertiesToOriginalValues()
    BaseEntity.AddTrackedOriginalValue(string, object)
    BaseEntity.SnapshotProperties()
    BaseEntity.RestoreFromSnapshot(Dictionary<string, object>)
    BaseEntity.IsBasePropertyName(string)
    BaseEntity.IsBaseRelationshipID(string)
    BaseEntity.OnPropertyChanging(string)
    BaseEntity.OnPropertyChanged(string)
    BaseEntity.Equals(IBaseEntity)
    BaseEntity.GetHashCode()
    BaseEntity.Equals(object)
    BaseEntity.Clone(object)
    BaseEntity.CopyFromSource(object)
    BaseEntity.TrackChanges
    BaseEntity.ModifiedByUserID_Label
    BaseEntity.ModifiedByUserID_Label_Silent
    BaseEntity.CanvasID_Label
    BaseEntity.CanvasID_Label_Silent
    BaseEntity.AlgorithmStepID_Label
    BaseEntity.AlgorithmStepID_Label_Silent
    BaseEntity.SafeID_Label
    BaseEntity.SafeID_Label_Silent
    BaseEntity.AccountID
    BaseEntity.ID
    BaseEntity.LastUpdated
    BaseEntity.ModifiedByUserID
    BaseEntity.CanvasID
    BaseEntity.AlgorithmStepID
    BaseEntity.SafeID
    BaseEntity.PropertyChanged
    BaseEntity.PropertyChanging
    object.GetType()
    object.MemberwiseClone()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: LemonEdge.API.Entities.Reporting
    Assembly: LemonEdge.API.Entities.Auto.dll
    Syntax
    [DataContract]
    public class SQLWrapper : BaseEntityWithPermissions, ISQLWrapper, IBaseEntityWithPermissions, ISetCopier, IHasVersion, IUserSpecific, IHasFolderStructure, IBaseEntity, IEquatable<IBaseEntity>, INotifyPropertyChanged, INotifyPropertyChanging, ICloneableAsync, ICanTrackProperties, ICloneableAsync<ISQLWrapper>, IUserSpecificPublicToggle, ISetItemLoaderOverride, ISetCopierCloneAlterer

    Constructors

    SQLWrapper()

    Declaration
    public SQLWrapper()

    Fields

    SQL_DUMMY_FUNCTION

    Declaration
    public const string SQL_DUMMY_FUNCTION = "\r\nALTER Function dbo.{0}\r\n(\r\n\t@accountID BigInt, \r\n\t@canvasID UniqueIdentifier = null, \r\n\t@teamID UniqueIdentifier, \r\n\t@userID UniqueIdentifier, \r\n\t@lastUpdated DateTimeOffset = null\r\n)\r\nRETURNS TABLE \r\nAS\r\nRETURN \r\n(\r\n\t-- Add the SELECT statement with parameter references here\r\n    -- Example Users\r\n\tSelect  Name, EmailLogin, ID \r\n    From    fn_Users(@accountID, @canvasID, @teamID, @userID, @lastUpdated)\r\n)\r\n"
    Field Value
    Type Description
    string

    SQL_DUMMY_SP

    Declaration
    public const string SQL_DUMMY_SP = "\r\nALTER Procedure dbo.{0}\r\n\t@accountID BigInt, \r\n\t@canvasID UniqueIdentifier = null, \r\n\t@teamID UniqueIdentifier, \r\n\t@userID UniqueIdentifier, \r\n\t@lastUpdated DateTimeOffset = null\r\nAS\r\nBEGIN\r\n\t-- SET NOCOUNT ON added to prevent extra result sets from\r\n\t-- interfering with SELECT statements.\r\n\tSET NOCOUNT ON;\r\n\r\n\t-- Insert statements for procedure here\r\n    -- Example Users\r\n\tSelect  Name, EmailLogin, ID \r\n    From    fn_Users(@accountID, @canvasID, @teamID, @userID, @lastUpdated)\r\nEND\r\n"
    Field Value
    Type Description
    string

    Properties

    AllowAsSubQuery

    Indicates this sql wrapper can be used as a sub query in other queries (such as via the dataset query tool)

    Declaration
    public bool AllowAsSubQuery { get; set; }
    Property Value
    Type Description
    bool

    AlwaysCreateInDatabase

    Indicates this sqlwrapper should always have its sql created in the database - including during saves/upgrades. This moves the initial performance hit of running a query for the first time to the save/upgrade process.

    Declaration
    public bool AlwaysCreateInDatabase { get; set; }
    Property Value
    Type Description
    bool

    AlwaysRecompileFunctionSQL

    Ensure the SQL of this function is recompiled on each call for higher performance.

    Declaration
    public bool AlwaysRecompileFunctionSQL { get; set; }
    Property Value
    Type Description
    bool

    AlwaysUseCoreSQL

    Indicates calling this sql wrapper should always use the core sql and never use any of the _Main, _AsOf, _Canvas performance alternatvies.

    Declaration
    public bool AlwaysUseCoreSQL { get; set; }
    Property Value
    Type Description
    bool

    CopierCloneType

    Declaration
    public SetCopierCloneType CopierCloneType { get; set; }
    Property Value
    Type Description
    SetCopierCloneType

    DefaultPagingRowCount

    The default number of rows to return in the grid display when paging results

    Declaration
    public int DefaultPagingRowCount { get; set; }
    Property Value
    Type Description
    int

    Description

    A user friendly description of this SQL Wrapper

    Declaration
    [StringLength(2000)]
    public string Description { get; set; }
    Property Value
    Type Description
    string

    DisplayItemOnCopy

    Indicates if the items should appear in the UI when copied from a grid. Typically child items shouldn't be added as items in a grid or opened on copy, just the root item itself

    Declaration
    public bool DisplayItemOnCopy { get; }
    Property Value
    Type Description
    bool

    FolderID

    The link to the folder this item is contained in

    Declaration
    public Guid? FolderID { get; set; }
    Property Value
    Type Description
    Guid?

    FolderID_Label

    Declaration
    public string FolderID_Label { get; set; }
    Property Value
    Type Description
    string

    FolderID_Label_Silent

    Declaration
    [NotMapped]
    public string FolderID_Label_Silent { get; set; }
    Property Value
    Type Description
    string

    ForceNewItemOnCopy

    Indicates if the specified item should always be created as a new item. For instance when copying sub transactions are always created as new items

    Declaration
    public bool ForceNewItemOnCopy { get; }
    Property Value
    Type Description
    bool

    GridNewItemType

    Indicates a new button will be shown on the grid that defaults to creating a new entity of the specified type

    Declaration
    public Guid? GridNewItemType { get; set; }
    Property Value
    Type Description
    Guid?

    GridPagingtype

    By default all queries first run a count to return the total number of rows then download just the first page of results. This flag prevents the execution of the count improving performance at the cost of knowing how many pages of data there is.

    Declaration
    [EnumDataType(typeof(SQLWrapperLoadType))]
    public SQLWrapperLoadType GridPagingtype { get; set; }
    Property Value
    Type Description
    SQLWrapperLoadType

    GridPagingtype_Tooltip

    Declaration
    [NotMapped]
    public string GridPagingtype_Tooltip { get; set; }
    Property Value
    Type Description
    string

    HelpURL

    A unique link to an html help page describing the purpose of this SQL Wrapper

    Declaration
    [StringLength(500)]
    public string HelpURL { get; set; }
    Property Value
    Type Description
    string

    IsPublic

    Indicates if this entity is visible to all users (public), or just the current user (private).

    Directly maps to UserID property

    Declaration
    [NotMapped]
    public bool IsPublic { get; set; }
    Property Value
    Type Description
    bool

    IsSystem

    Indicates this item is part of the core system. Any changes will be overwritten if the version number is lower than the provided version number and the item is also marked as a system item.

    Declaration
    [Required]
    public bool IsSystem { get; set; }
    Property Value
    Type Description
    bool

    Name

    [Key] The unique user friendly name of this SQL Wrapper

    Declaration
    [Unique]
    [Required]
    [StringLength(500)]
    public string Name { get; set; }
    Property Value
    Type Description
    string

    OnlySystemQueryable

    Indicates this sql wrapper is a normal one and can be executed by the user if false. Dataset Shortcuts are examples of sqlwrappers that are not directly queryable and have this as true

    Declaration
    public bool OnlySystemQueryable { get; set; }
    Property Value
    Type Description
    bool

    OwnerEntityID

    A link to the entity that owns this SQL Wrapper and is responsible for dynamically generating its SQL such as the IDataset entity type.

    Declaration
    public Guid? OwnerEntityID { get; set; }
    Property Value
    Type Description
    Guid?

    OwnerEntityID_Label

    Declaration
    public string OwnerEntityID_Label { get; set; }
    Property Value
    Type Description
    string

    OwnerEntityID_Label_Silent

    Declaration
    [NotMapped]
    public string OwnerEntityID_Label_Silent { get; set; }
    Property Value
    Type Description
    string

    OwnerEntityType

    An entity type that owns this SQL Wrapper and is responsible for dynamically generating its SQL such as the IDataset entity type.

    Declaration
    public Guid? OwnerEntityType { get; set; }
    Property Value
    Type Description
    Guid?

    SQL

    The sql to be wrapped. This should start with an [alter function dbo.] or [alter procedure dbo.].

    Declaration
    [Required]
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQL)", "MyItem.SQL.Trim().Replace(\"[\", \"\").Replace(\"]\", \"\").StartsWith((MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.Function ? \"alter function dbo.\" : \"alter procedure dbo.\") + MyItem.SQLName, StringComparison.InvariantCultureIgnoreCase)", "Must start with 'alter function dbo.' or 'alter procedure dbo.'")]
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQL)", "!MyItem.SQL.ContainsWholeWord(\"go\", StringComparison.InvariantCultureIgnoreCase) && !MyItem.SQL.ContainsWholeWord(\"drop\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"drop table #\" }) && !MyItem.SQL.ContainsWholeWord(\"create\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"create table #\", \"create index\" }) && (!MyItem.SQL.ContainsWholeWord(\"exec\", StringComparison.InvariantCultureIgnoreCase) || MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.StoredProcedure)", "Contains invalid sql.")]
    public string SQL { get; set; }
    Property Value
    Type Description
    string

    SQLAsOf

    The sql to be wrapped that doesn't reference a canvas, this is optional for performance it is dynsmically created from main SQL anyway. This should start with an [alter function dbo.] or [alter procedure dbo.] and the name should end with _AsOf.

    Declaration
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQLAsOf)", "MyItem.SQLAsOf.Trim().Replace(\"[\", \"\").Replace(\"]\", \"\").StartsWith((MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.Function ? \"alter function dbo.\" : \"alter procedure dbo.\") + MyItem.SQLName + \"_AsOf\", StringComparison.InvariantCultureIgnoreCase)", "Must start with 'alter function dbo.' or 'alter procedure dbo.'")]
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQLAsOf)", "!MyItem.SQLAsOf.ContainsWholeWord(\"go\", StringComparison.InvariantCultureIgnoreCase) && !MyItem.SQLAsOf.ContainsWholeWord(\"drop\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"drop table #\" }) && !MyItem.SQLAsOf.ContainsWholeWord(\"create\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"create table #\", \"create index\" }) && (!MyItem.SQL.ContainsWholeWord(\"exec\", StringComparison.InvariantCultureIgnoreCase) || MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.StoredProcedure)", "Contains invalid sql.")]
    public string SQLAsOf { get; set; }
    Property Value
    Type Description
    string

    SQLCanvas

    The sql to be wrapped that doesn't reference an as of date, this is optional for performance it is dynsmically created from main SQL anyway. This should start with an [alter function dbo.] or [alter procedure dbo.] and the name should end with _Canvas.

    Declaration
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQLCanvas)", "MyItem.SQLCanvas.Trim().Replace(\"[\", \"\").Replace(\"]\", \"\").StartsWith((MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.Function ? \"alter function dbo.\" : \"alter procedure dbo.\") + MyItem.SQLName + \"_Canvas\", StringComparison.InvariantCultureIgnoreCase)", "Must start with 'alter function dbo.' or 'alter procedure dbo.'")]
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQLCanvas)", "!MyItem.SQLCanvas.ContainsWholeWord(\"go\", StringComparison.InvariantCultureIgnoreCase) && !MyItem.SQLCanvas.ContainsWholeWord(\"drop\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"drop table #\" }) && !MyItem.SQLCanvas.ContainsWholeWord(\"create\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"create table #\", \"create index\" }) && (!MyItem.SQL.ContainsWholeWord(\"exec\", StringComparison.InvariantCultureIgnoreCase) || MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.StoredProcedure)", "Contains invalid sql.")]
    public string SQLCanvas { get; set; }
    Property Value
    Type Description
    string

    SQLMain

    The sql to be wrapped that doesn't reference an as of date or canvas, this is optional for performance it is dynsmically created from main SQL anyway. This should start with an [alter function dbo.] or [alter procedure dbo.] and the name should end with _Main.

    Declaration
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQLMain)", "MyItem.SQLMain.Trim().Replace(\"[\", \"\").Replace(\"]\", \"\").StartsWith((MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.Function ? \"alter function dbo.\" : \"alter procedure dbo.\") + MyItem.SQLName + \"_Main\", StringComparison.InvariantCultureIgnoreCase)", "Must start with 'alter function dbo.' or 'alter procedure dbo.'")]
    [PropertyValidation("!string.IsNullOrEmpty(MyItem.SQLMain)", "!MyItem.SQLMain.ContainsWholeWord(\"go\", StringComparison.InvariantCultureIgnoreCase) && !MyItem.SQLMain.ContainsWholeWord(\"drop\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"drop table #\" }) && !MyItem.SQLMain.ContainsWholeWord(\"create\", StringComparison.InvariantCultureIgnoreCase, new string[] { \"create table #\", \"create index\" }) && (!MyItem.SQL.ContainsWholeWord(\"exec\", StringComparison.InvariantCultureIgnoreCase) || MyItem.Type == LemonEdge.API.Entities.Reporting.SQLWrapperType.StoredProcedure)", "Contains invalid sql.")]
    public string SQLMain { get; set; }
    Property Value
    Type Description
    string

    SQLName

    The actual name of this stored procedure or function in the sql database

    Declaration
    [Unique]
    [Required]
    [StringLength(500)]
    public string SQLName { get; set; }
    Property Value
    Type Description
    string

    Type

    The type of sql this SQL Wrapper is wrapping: Function or Stored Procedure

    Declaration
    [EnumDataType(typeof(SQLWrapperType))]
    public SQLWrapperType Type { get; set; }
    Property Value
    Type Description
    SQLWrapperType

    Type_Tooltip

    Declaration
    [NotMapped]
    public string Type_Tooltip { get; set; }
    Property Value
    Type Description
    string

    UserID

    Links to IUser. Indicates if this entity record is private to just the specified user, or if it is public to everyone (holding null)

    Declaration
    public Guid? UserID { get; set; }
    Property Value
    Type Description
    Guid?

    UserID_Label

    Declaration
    public string UserID_Label { get; set; }
    Property Value
    Type Description
    string

    UserID_Label_Silent

    Declaration
    [NotMapped]
    public string UserID_Label_Silent { get; set; }
    Property Value
    Type Description
    string

    Version

    Indicates the version number of this item. Changes will only be overwritten if the provided new item has a higer version number than this one.

    Declaration
    [Required]
    [DatabasePropertyValidation("MyItem.IsSystem", "var allUserTeams = await Cache.GetAllItems<LemonEdge.API.Entities.Administration.IUserTeam>(); (await Cache.GetAllItems<LemonEdge.API.Entities.Administration.ITeam>()).Any(x => allUserTeams.Where(ut => ut.UserID == User.ID).Select(ut => ut.TeamID).Contains(x.ID) && x.CanEditSystemItems)", "User is not authorized to modify system items.")]
    public short Version { get; set; }
    Property Value
    Type Description
    short

    Methods

    AlterCopiedItem(IEntityUpdater, UserInfo, IReadOnlyCache, IBaseEntity)

    A custom ability to alter this item when it is was copied by the user in the UI, not when it is being imported

    Declaration
    public Task AlterCopiedItem(IEntityUpdater host, UserInfo user, IReadOnlyCache cache, IBaseEntity sourceItem)
    Parameters
    Type Name Description
    IEntityUpdater host

    The context this item was copied into

    UserInfo user

    The current user

    IReadOnlyCache cache

    The current local cache

    IBaseEntity sourceItem

    The original source item this item was copied from

    Returns
    Type Description
    Task

    A task inidicating the finishing of this method

    CopyFromEntity(IBaseEntity)

    Declaration
    protected override void CopyFromEntity(IBaseEntity src)
    Parameters
    Type Name Description
    IBaseEntity src
    Overrides
    BaseEntity.CopyFromEntity(IBaseEntity)

    CopyFromSource(ISQLWrapper)

    Updates all properties in this item to have the same properties as the source object.

    Declaration
    public void CopyFromSource(ISQLWrapper source)
    Parameters
    Type Name Description
    ISQLWrapper source

    The source object to copy all values from.

    CopyRelatedItem(IBaseEntity, EntityRelationship)

    Determines whether the source item should be copied based on the provided relationship

    Declaration
    public bool CopyRelatedItem(IBaseEntity sourceItem, EntityRelationship rel)
    Parameters
    Type Name Description
    IBaseEntity sourceItem

    The original source item this item was copied from

    EntityRelationship rel

    The particular relationship from the source item

    Returns
    Type Description
    bool

    GetAutoUpdated()

    Indicates if the changes to the sql for this sql wrapper were made automatically (such as by an IDataset) or by the user manually

    Declaration
    public bool GetAutoUpdated()
    Returns
    Type Description
    bool

    GetPropertyValue(ISetItemInfo, string, object)

    Declaration
    public object GetPropertyValue(ISetItemInfo info, string propName, object currentValue)
    Parameters
    Type Name Description
    ISetItemInfo info
    string propName
    object currentValue
    Returns
    Type Description
    object

    ResetDefaultSQL()

    Declaration
    public void ResetDefaultSQL()

    SetAutoUpdated()

    Sets internally that this sql wrapper had its sql modified internally by the LemonEdge platform.

    Used as sometimes sql is not allowed to be modified against a sql wrapper

    Declaration
    public void SetAutoUpdated()

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()

    Implements

    ISQLWrapper
    IBaseEntityWithPermissions
    ISetCopier
    IHasVersion
    IUserSpecific
    IHasFolderStructure
    IBaseEntity
    IEquatable<T>
    INotifyPropertyChanged
    INotifyPropertyChanging
    ICloneableAsync
    ICanTrackProperties
    ICloneableAsync<T>
    IUserSpecificPublicToggle
    ISetItemLoaderOverride
    ISetCopierCloneAlterer

    Extension Methods

    LinqExtensions.AsArray<T>(T)
    LinqExtensions.ToArrayOfOne<T>(T)
    LinqExtensions.ToListOfOne<T>(T)
    MiscExtensions.SetIfNotEqual<T, TP>(T, Expression<Func<T, TP>>, TP)
    WeakReferenceExtensions.WeakReference(object)
    SQLExtensions.ToSQLValue(object, bool)
    ReflectionExtensions.ClearEventInvocations(object, string)
    StringExtensions.ToCSVFormatString(object, Type)
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.