本文整理汇总了C#中DataConnection类的典型用法代码示例。如果您正苦于以下问题:C# DataConnection类的具体用法?C# DataConnection怎么用?C# DataConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataConnection类属于命名空间,在下文中一共展示了DataConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPackageList
public List<PackageDescriptor> GetPackageList(Guid InstallationId, string Culture)
{
using (DataConnection connection = new DataConnection())
{
return (
from package in connection.Get<Package>().AsEnumerable()
join media in connection.Get<IMediaFile>() on package.PackageFile equals media.KeyPath
select new PackageDescriptor()
{
Id = package.PackageId,
Name = package.Name,
GroupName = package.GroupName,
PackageVersion = package.PackageVersion,
MinCompositeVersionSupported = package.MinCompositeVersionSupported,
MaxCompositeVersionSupported = package.MaxCompositeVersionSupported,
Author = package.Author,
Description = package.Description,
TechicalDetails = package.TechnicalDetails,
EulaId = package.EULA,
ReadMoreUrl = package.ReadMoreUrl,
IsFree = true,
PackageFileDownloadUrl = new Uri(Context.Request.Url, UrlUtils.ResolvePublicUrl("Renderers/ShowMedia.ashx?id=" + media.Id)).OriginalString
}
).ToList();
}
}
示例2: GetColumns
protected override List<ColumnInfo> GetColumns(DataConnection dataConnection)
{
var sql = @"
SELECT
TABSCHEMA,
TABNAME,
COLNAME,
LENGTH,
SCALE,
NULLS,
IDENTITY,
COLNO,
TYPENAME,
REMARKS
FROM
SYSCAT.COLUMNS
WHERE
" + GetSchemaFilter("TABSCHEMA");
return _columns = dataConnection.Query(
rd => new ColumnInfo
{
TableID = dataConnection.Connection.Database + "." + rd.GetString(0) + "." + rd.GetString(1),
Name = rd.ToString(2),
Length = Converter.ChangeTypeTo<long>(rd[3]),
Scale = Converter.ChangeTypeTo<int> (rd[4]),
IsNullable = rd.ToString(5) == "Y",
IsIdentity = rd.ToString(6) == "Y",
Ordinal = Converter.ChangeTypeTo<int>(rd[7]),
DataType = rd.ToString(8),
Description = rd.ToString(9),
},
sql).ToList();
}
示例3: GetForeignKeys
protected override List<ForeingKeyInfo> GetForeignKeys(DataConnection dataConnection)
{
const string baseSql = @"
SELECT
o.name as Name,
c.tableid as ThisTableID,
r.reftabid as OtherTableID,
COL_NAME(c.tableid, r.fokey{0}) as ThisColumn,
COL_NAME(r.reftabid, r.refkey{0}) as OtherColumn,
{0} as Ordinal
FROM
sysreferences r
JOIN sysconstraints c ON r.constrid = c.constrid
JOIN sysobjects o ON c.constrid = o.id
JOIN sysobjects o3 ON c.tableid = o3.id
LEFT JOIN sysobjects o2 ON r.reftabid = o2.id
JOIN sysreferences r2 ON r.constrid = r2.constrid
LEFT JOIN sysindexes i ON r2.indexid = i.indid AND r2.reftabid = i.id
WHERE
c.status = 64";
string sql = null;
for (var i = 1; i <= 16; i++)
{
if (sql != null)
sql += "\nUNION ALL";
sql += string.Format(baseSql, i);
}
sql = "SELECT * FROM (" + sql + ") as t WHERE ThisColumn IS NOT NULL";
return dataConnection.Query<ForeingKeyInfo>(sql).ToList();
}
示例4: GetForeignKeys
protected override List<ForeingKeyInfo> GetForeignKeys(DataConnection dataConnection)
{
return dataConnection.Query<ForeingKeyInfo>(@"
SELECT
rc.CONSTRAINT_NAME as Name,
fk.TABLE_CATALOG + '.' + fk.TABLE_SCHEMA + '.' + fk.TABLE_NAME as ThisTableID,
fk.COLUMN_NAME as ThisColumn,
pk.TABLE_CATALOG + '.' + pk.TABLE_SCHEMA + '.' + pk.TABLE_NAME as OtherTableID,
pk.COLUMN_NAME as OtherColumn,
pk.ORDINAL_POSITION as Ordinal
FROM
INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc
JOIN
INFORMATION_SCHEMA.KEY_COLUMN_USAGE fk
ON
fk.CONSTRAINT_CATALOG = rc.CONSTRAINT_CATALOG AND
fk.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA AND
fk.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
JOIN
INFORMATION_SCHEMA.KEY_COLUMN_USAGE pk
ON
pk.CONSTRAINT_CATALOG = rc.UNIQUE_CONSTRAINT_CATALOG AND
pk.CONSTRAINT_SCHEMA = rc.UNIQUE_CONSTRAINT_SCHEMA AND
pk.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME
WHERE
fk.ORDINAL_POSITION = pk.ORDINAL_POSITION
ORDER BY
ThisTableID,
Ordinal")
.ToList();
}
示例5: GetPrimaryKeys
protected override List<PrimaryKeyInfo> GetPrimaryKeys(DataConnection dataConnection)
{
var dbConnection = (DbConnection)dataConnection.Connection;
var pks = dbConnection.GetSchema("IndexColumns");
var idxs = dbConnection.GetSchema("Indexes");
return
(
from pk in pks. AsEnumerable()
join idx in idxs.AsEnumerable()
on
pk. Field<string>("INDEX_CATALOG") + "." +
pk. Field<string>("INDEX_SCHEMA") + "." +
pk. Field<string>("INDEX_NAME") + "." +
pk. Field<string>("TABLE_NAME")
equals
idx.Field<string>("INDEX_CATALOG") + "." +
idx.Field<string>("INDEX_SCHEMA") + "." +
idx.Field<string>("INDEX_NAME") + "." +
idx.Field<string>("TABLE_NAME")
where idx.Field<bool>("PRIMARY")
select new PrimaryKeyInfo
{
TableID = pk.Field<string>("INDEX_SCHEMA") + ".." + pk.Field<string>("TABLE_NAME"),
PrimaryKeyName = pk.Field<string>("INDEX_NAME"),
ColumnName = pk.Field<string>("COLUMN_NAME"),
Ordinal = pk.Field<int> ("ORDINAL_POSITION"),
}
).ToList();
}
示例6: Pref
public static string Pref(string prefName)
{
string command="SELECT ValueString FROM preference WHERE PrefName='"+POut.String(prefName)+"'";
DataConnection dcon=new DataConnection();
DataTable table=dcon.GetTable(command);
return table.Rows[0][0].ToString();
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var reportId = Guid.Parse(this.Request["id"].ToString());
var reportType = this.Request["type"].ToString();
var pageUrl = string.Empty;
using (DataConnection con = new DataConnection())
{
var report = con.Get<Composite.Forms.JotFormReport>().Where(r => r.Id == reportId).SingleOrDefault();
if (report != null)
{
switch (reportType)
{
case "grid": pageUrl = report.GridReportURL; break;
case "table": pageUrl = report.TableReportURL; break;
case "visual": pageUrl = report.VisualReportURL; break;
case "excel": pageUrl = report.ExcelReportURL; break;
case "csv": pageUrl = report.CsvReportURL; break;
default: break;
}
}
}
if (!string.IsNullOrWhiteSpace(pageUrl))
{
lPrintFrame.Text = string.Format(@"<iframe src=""{0}"" frameborder=""0"" style=""width:100%; height:100%; min-height:450px; border:none;"" ></iframe>", pageUrl);
}
else
{
lPrintFrame.Text = "<div style='padding: 20px'><h2>Report is not available</h2><p>The URL for this report has not been specified. To remedy this, edit this report and specify the JotForm Report URL.</p></div>";
}
}
示例8: Render
protected override void Render(HtmlTextWriter writer)
{
string description = Page.Header.Description;
if (string.IsNullOrWhiteSpace(description) && SiteMap.CurrentNode != null)
{
description = SiteMap.CurrentNode.Description;
}
if (string.IsNullOrWhiteSpace(description))
{
using (DataConnection connection = new DataConnection())
{
description = connection.SitemapNavigator.CurrentPageNode.Description;
}
}
if (string.IsNullOrWhiteSpace(description)) return;
if (_element != null)
{
_element.Add(description);
string commonNs = string.Format(" xmlns=\"{0}\"", Namespaces.Xhtml );
string raw = _element.ToString().Replace(commonNs, "");
writer.Write(raw);
}
else
{
writer.WriteEncodedText(description);
}
}
示例9: GetDataTypes
protected override List<DataTypeInfo> GetDataTypes(DataConnection dataConnection)
{
var dts = base.GetDataTypes(dataConnection);
if (dts.All(dt => dt.ProviderDbType != 128))
{
dts.Add(new DataTypeInfo
{
TypeName = "image",
DataType = typeof(byte[]).FullName,
CreateFormat = "image({0})",
CreateParameters = "length",
ProviderDbType = 128
});
}
if (dts.All(dt => dt.ProviderDbType != 130))
{
dts.Add(new DataTypeInfo
{
TypeName = "text",
DataType = typeof(string).FullName,
CreateFormat = "text({0})",
CreateParameters = "length",
ProviderDbType = 130
});
}
return dts;
}
示例10: loadvisits
public void loadvisits(int studentID, DateTime minDate, DateTime maxDate)
{
min = minDate;
max = maxDate;
ID = studentID;
//clears the list box to enter new information
listBoxEditVisit.Items.Clear();
//TAB THIS
listBoxEditVisit.Items.Add("DATE".PadRight(15) + "\t" + "FIRST NAME".PadRight(30) + "\t" + "LAST NAME".PadRight(30) + "\t" + "ID".PadRight(12)+ "\t" + "TIME IN".PadRight(10)+"\t" + "TIME OUT".PadRight(10) + "\t" + "METHOD".PadRight(20) + "\t" + "TUTOR'S FIRST NAME".PadRight(30) + "TUTOR'S LAST NAME".PadRight(30)+ "\t" + "SUBJECT" + "\t" + "CATALOG" + "\t" + "SECTION");
//creates new dataconnection
DataConnection conn = new DataConnection();
SqlDataReader rd;
conn.Open();
//gets visits request
//just added STUDENT.FIRSTNAME, STUDENT.LASTNAME, STUDENT TABLE
rd = conn.joinQuery("SELECT VISIT.CLARION_ID, VISIT.DATE, VISIT.TIME_IN, VISIT.TIME_OUT, STUDENT.FIRSTNAME, STUDENT.LASTNAME, VISIT.METHOD, TUTOR.TUTOR_ID, SUBJECT, CATALOG, S_TUTOR.FIRSTNAME AS TUTORFIRSTNAME, S_TUTOR.LASTNAME AS TUTORLASTNAME, SECTION FROM VISIT INNER JOIN student on visit.clarion_id = student.clarion_id LEFT JOIN TUTOR ON VISIT.TUTOR_ID = TUTOR.TUTOR_ID LEFT JOIN STUDENT S_TUTOR ON TUTOR.CLARION_ID = S_TUTOR.CLARION_ID WHERE visit.DATE<='" + maxDate + "' AND visit.DATE>='" + minDate + (studentID == 0 ? "'":"' AND VISIT.CLARION_ID = '" + studentID + "'") + " ORDER BY DATE, TIME_IN");
if (rd.HasRows)
{
while (rd.Read())
{
DateTime thedate = DateTime.Parse(rd["DATE"].ToString());
string TIMEOUT = rd["TIME_OUT"].ToString().PadRight(10);
if (TIMEOUT.Replace(" ","").Length !=8)
TIMEOUT = " ".PadRight(18);
listBoxEditVisit.Items.Add(thedate.ToString("d").PadRight(15) + "\t" + rd["FIRSTNAME"].ToString().PadRight(30) + "\t" + rd["LASTNAME"].ToString().PadRight(30) + "\t" + (int.Parse(rd["CLARION_ID"].ToString())).ToString("D8").PadRight(12) + "\t" + rd["TIME_IN"].ToString().PadRight(10) + "\t" + TIMEOUT.PadRight(10) + "\t" + rd["METHOD"].ToString().PadRight(20) + "\t" + rd["TUTORFIRSTNAME"].ToString().PadRight(30) + " " + rd["TUTORLASTNAME"].ToString().PadRight(30) + "\t" + rd["SUBJECT"].ToString().PadRight(5) + "\t" + ((rd["CATALOG"]).ToString()).PadRight(5) + "\t" + ((rd["SECTION"]).ToString()).PadRight(4));
}
}
rd.Close();
//closes connection
conn.Close();
if (studentID == 0)
{
conn.Open();
//gets visits request
//just added STUDENT.FIRSTNAME, STUDENT.LASTNAME, STUDENT TABLE
// rd = conn.joinQuery("SELECT VISIT.CLARION_ID, VISIT.DATE, VISIT.TIME_IN, VISIT.TIME_OUT, STUDENT.FIRSTNAME, STUDENT.LASTNAME, VISIT.METHOD, TUTOR.TUTOR_ID, SUBJECT, CATALOG, S_TUTOR.FIRSTNAME AS TUTORFIRSTNAME, S_TUTOR.LASTNAME AS TUTORLASTNAME, SECTION FROM VISIT INNER JOIN student on visit.clarion_id = student.clarion_id LEFT JOIN TUTOR ON VISIT.TUTOR_ID = TUTOR.TUTOR_ID LEFT JOIN STUDENT S_TUTOR ON TUTOR.CLARION_ID = S_TUTOR.CLARION_ID WHERE visit.DATE<='" + maxDate + "' AND visit.DATE>='" + minDate + (studentID == 0 ? "'" : "' AND VISIT.CLARION_ID = '" + studentID + "'") + " ORDER BY DATE, TIME_IN");
rd = conn.joinQuery("select tutor_hour.tutor_id, tutor_hour.date, tutor_hour.time_out ,tutor_hour.time_difference, tutor_hour.time_in, student.lastname, student.firstname from tutor_hour inner join tutor on tutor_hour.tutor_id = tutor.tutor_id inner join student on tutor.clarion_id = student.clarion_id where tutor_hour.DATE<='" + maxDate + "' AND tutor_hour.DATE>='" + minDate+"' ");
if (rd.HasRows)
{
while (rd.Read())
{
DateTime thedate = DateTime.Parse(rd["DATE"].ToString());
string TIMEOUT = rd["TIME_OUT"].ToString().PadRight(10);
if (TIMEOUT.Replace(" ", "").Length != 8)
TIMEOUT = " ".PadRight(18);
listBoxEditVisit.Items.Add(thedate.ToString("d").PadRight(15) + "\t" + rd["FIRSTNAME"].ToString().PadRight(30) + "\t" + rd["LASTNAME"].ToString().PadRight(30) + "\t" + ("TUT" + int.Parse(rd["tutor_ID"].ToString()).ToString("D4").PadRight(10)) + "\t" + rd["TIME_IN"].ToString().PadRight(10) + "\t" + rd["TIME_OUT"].ToString().PadRight(10) + "\t" + "TUTOR");
}
}
rd.Close();
//closes connection
conn.Close();
}
}
示例11: GetCustomEditorSettings
/// <summary>
/// Returns a relative path a to a custom funtion call editor for the specified function.
/// </summary>
/// <param name="functionName">The function name</param>
/// <returns>A relative path to a custom call editor, or <value>null</value> if no custom editor was defined.</returns>
public static FunctionCallEditorSettings GetCustomEditorSettings(string functionName)
{
var settings = _customEditorSettings[functionName];
if (settings != null)
{
return settings;
}
using (var c = new DataConnection())
{
var mapping = c.Get<ICustomFunctionCallEditorMapping>().FirstOrDefault(e => e.FunctionName == functionName);
if (mapping != null)
{
return new FunctionCallEditorSettings
{
Url = UrlUtils.ResolvePublicUrl(mapping.CustomEditorPath),
Width = mapping.Width,
Height = mapping.Height
};
}
}
return null;
}
示例12: GetPrimaryKeys
protected override List<PrimaryKeyInfo> GetPrimaryKeys(DataConnection dataConnection)
{
return _primaryKeys = dataConnection.Query(
rd => new PrimaryKeyInfo
{
TableID = dataConnection.Connection.Database + "." + rd.ToString(0) + "." + rd.ToString(1),
PrimaryKeyName = rd.ToString(2),
ColumnName = rd.ToString(3),
Ordinal = Converter.ChangeTypeTo<int>(rd[4])
},@"
SELECT
col.TBCREATOR,
col.TBNAME,
idx.NAME,
col.NAME,
col.KEYSEQ
FROM
SYSIBM.SYSCOLUMNS col
JOIN SYSIBM.SYSINDEXES idx ON
col.TBCREATOR = idx.TBCREATOR AND
col.TBNAME = idx.TBNAME
WHERE
col.KEYSEQ > 0 AND idx.UNIQUERULE = 'P' AND " + GetSchemaFilter("col.TBCREATOR") + @"
ORDER BY
col.TBCREATOR, col.TBNAME, col.KEYSEQ")
.ToList();
}
示例13: GetDataTypes
protected override List<DataTypeInfo> GetDataTypes(DataConnection dataConnection)
{
return new List<DataTypeInfo>
{
new DataTypeInfo { TypeName = "XML", CreateParameters = null, DataType = "System.String" },
new DataTypeInfo { TypeName = "DECFLOAT", CreateParameters = "PRECISION", DataType = "System.Decimal" },
new DataTypeInfo { TypeName = "DBCLOB", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "CLOB", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "BLOB", CreateParameters = "LENGTH", DataType = "System.Byte[]" },
new DataTypeInfo { TypeName = "LONG VARGRAPHIC", CreateParameters = null, DataType = "System.String" },
new DataTypeInfo { TypeName = "VARGRAPHIC", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "GRAPHIC", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "BIGINT", CreateParameters = null, DataType = "System.Int64" },
new DataTypeInfo { TypeName = "LONG VARCHAR FOR BIT DATA", CreateParameters = null, DataType = "System.Byte[]" },
new DataTypeInfo { TypeName = "VARCHAR () FOR BIT DATA", CreateParameters = "LENGTH", DataType = "System.Byte[]" },
new DataTypeInfo { TypeName = "VARBIN", CreateParameters = "LENGTH", DataType = "System.Byte[]" },
new DataTypeInfo { TypeName = "BINARY", CreateParameters = "LENGTH", DataType = "System.Byte[]" },
new DataTypeInfo { TypeName = "CHAR () FOR BIT DATA", CreateParameters = "LENGTH", DataType = "System.Byte[]" },
new DataTypeInfo { TypeName = "LONG VARCHAR", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "CHARACTER", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "CHAR", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "DECIMAL", CreateParameters = "PRECISION,SCALE", DataType = "System.Decimal" },
new DataTypeInfo { TypeName = "INTEGER", CreateParameters = null, DataType = "System.Int32" },
new DataTypeInfo { TypeName = "SMALLINT", CreateParameters = null, DataType = "System.Int16" },
new DataTypeInfo { TypeName = "REAL", CreateParameters = null, DataType = "System.Single" },
new DataTypeInfo { TypeName = "DOUBLE", CreateParameters = null, DataType = "System.Double" },
new DataTypeInfo { TypeName = "VARCHAR", CreateParameters = "LENGTH", DataType = "System.String" },
new DataTypeInfo { TypeName = "DATE", CreateParameters = null, DataType = "System.DateTime" },
new DataTypeInfo { TypeName = "TIME", CreateParameters = null, DataType = "System.TimeSpan" },
new DataTypeInfo { TypeName = "TIMESTAMP", CreateParameters = null, DataType = "System.DateTime" },
new DataTypeInfo { TypeName = "TIMESTMP", CreateParameters = null, DataType = "System.DateTime" },
new DataTypeInfo { TypeName = "ROWID", CreateParameters = "LENGTH", DataType = "System.Byte[]" },
};
}
示例14: GetColumns
protected override List<ColumnInfo> GetColumns(DataConnection dataConnection)
{
var sql = @"
SELECT
TBCREATOR,
TBNAME,
NAME,
LENGTH,
SCALE,
NULLS,
CASE WHEN DEFAULT IN ('I', 'J') THEN 'Y' ELSE 'N' END,
COLNO,
COLTYPE,
REMARKS
FROM
SYSIBM.SYSCOLUMNS
WHERE
" + GetSchemaFilter("TBCREATOR");
return dataConnection.Query(
rd => new ColumnInfo
{
TableID = dataConnection.Connection.Database + "." + rd.GetString(0) + "." + rd.GetString(1),
Name = rd.ToString(2),
Length = Converter.ChangeTypeTo<int>(rd[3]),
Scale = Converter.ChangeTypeTo<int>(rd[4]),
IsNullable = rd.ToString(5) == "Y",
IsIdentity = rd.ToString(6) == "Y",
Ordinal = Converter.ChangeTypeTo<int>(rd[7]),
DataType = rd.ToString(8),
Description = rd.ToString(9),
},
sql).ToList();
}
示例15: GetPrimaryKeys
protected override List<PrimaryKeyInfo> GetPrimaryKeys(DataConnection dataConnection)
{
return dataConnection.Query(rd =>
{
var constraint = rd.IsDBNull(3) ? null : rd.GetString(3);
if (constraint != "PRIMARY KEY")
return null;
var schema = rd.GetString(0);
var tableName = rd.GetString(1);
var indexName = rd.GetString(2);
var columnName = rd.GetString(4);
var position = rd.GetInt32(5);
return new PrimaryKeyInfo
{
TableID = String.Concat(schema, '.', tableName),
ColumnName = columnName,
Ordinal = position,
PrimaryKeyName = indexName
};
}, @"
SELECT
SCHEMA_NAME,
TABLE_NAME,
INDEX_NAME,
CONSTRAINT,
COLUMN_NAME,
POSITION
FROM INDEX_COLUMNS")
.Where(x => x != null).ToList();
}