本文整理汇总了C#中DataConnection.Get方法的典型用法代码示例。如果您正苦于以下问题:C# DataConnection.Get方法的具体用法?C# DataConnection.Get怎么用?C# DataConnection.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataConnection
的用法示例。
在下文中一共展示了DataConnection.Get方法的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: InitializeViewState
public override void InitializeViewState()
{
_selectedKeys = SelectedAsString.Split(',').ToList();
using (var con = new DataConnection())
{
var types = con.Get<TagType>().OrderBy(t => t.Name);
_tags = con.Get<Tags>().ToList();
tagTypesRepeater.DataSource = types;
tagTypesRepeater.DataBind();
}
}
示例3: httpApplication_BeginRequest
static void httpApplication_BeginRequest(object sender, EventArgs e)
{
var httpApplication = (HttpApplication)sender;
var incomingUrlPath = HttpUtility.UrlDecode(httpApplication.Context.Request.Url.PathAndQuery.TrimEnd(new[] { '/' }));
try
{
if (httpApplication.Request.Url.AbsolutePath.StartsWith("/Composite",
StringComparison.InvariantCultureIgnoreCase))
{
// Let's leave Composite alone so the user aren't able to lock themselves out of the console.
return;
}
else if (httpApplication.Request.Url.AbsolutePath == "/UrlAlias/Preview")
{
var location = HttpUtility.UrlDecode(httpApplication.Request["p"]);
httpApplication.Response.Redirect(location, false);
}
else
{
using (var conn = new DataConnection())
{
var matchingUrlAlias =
conn.Get<IUrlAlias>()
.SingleOrDefault(x => x.UrlAlias.ToLower() == incomingUrlPath.ToLower());
if (matchingUrlAlias != null
&& matchingUrlAlias.Enabled
&& (matchingUrlAlias.Hostname == Guid.Empty || conn.Get<IHostnameBinding>()
.Single(x => x.Id == matchingUrlAlias.Hostname).Hostname == httpApplication.Request.Url.Host))
{
matchingUrlAlias.LastUse = DateTime.Now;
matchingUrlAlias.UseCount++;
conn.Update(matchingUrlAlias);
httpApplication.Response.Clear();
httpApplication.Response.StatusCode = matchingUrlAlias.HttpStatusCode;
httpApplication.Response.RedirectLocation = matchingUrlAlias.RedirectLocation;
httpApplication.Response.End();
}
}
}
}
catch (ThreadAbortException ex)
{
// Do nothing, this is expected
}
catch (Exception ex)
{
LoggingService.LogError("Url Aliases", ex);
}
}
示例4: GetGenericBackgroundPaths
private static IEnumerable<string> GetGenericBackgroundPaths()
{
using (var connection = new DataConnection())
{
string folderPath = connection.Get<IMediaFileFolder>().Where(f => f.Id == Settings.GenericGroupViewImageFolderId).Select(f => f.Path).FirstOrDefault();
var paths = connection.Get<IImageFile>().Where(f => f.FolderPath == folderPath).Select(f => f.CompositePath);
foreach (string imageId in paths)
{
yield return GetImagePathFromId(imageId, Settings.GroupViewImageWidth, Settings.GroupViewImageHeight, "fill");
}
}
}
示例5: GetEulaText
public string GetEulaText(Guid eulaId, string userCulture)
{
using (DataConnection connection = new DataConnection())
{
return connection.Get<EULA>().Where(d => d.Id == eulaId).Select(d => d.Text).FirstOrDefault();
};
}
示例6: Get
// Getting a product by id
public Product Get(Guid id)
{
using (var c = new DataConnection())
{
return c.Get<Product>().FirstOrDefault(p => p.Id == id);
}
}
示例7: GetPageTemplates
public IEnumerable<PageTemplateDescriptor> GetPageTemplates()
{
using (var conn = new DataConnection(PublicationScope.Published))
{
var result = new List<PageTemplateDescriptor>();
foreach (var xmlPageTemplate in conn.Get<IXmlPageTemplate>())
{
string defaultPlaceholderId;
PlaceholderDescriptor[] placeholders;
ParseLayoutFile(xmlPageTemplate, out placeholders, out defaultPlaceholderId);
PageTemplateDescriptor descriptor = new XmlPageTemplateDescriptor(xmlPageTemplate)
{
Id = xmlPageTemplate.Id,
Title = xmlPageTemplate.Title,
DefaultPlaceholderId = defaultPlaceholderId,
PlaceholderDescriptions = placeholders
};
result.Add(descriptor);
}
return result;
}
}
示例8: 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>";
}
}
示例9: 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;
}
示例10: Rate
public string Rate(string score, string ratyId)
{
Guid ratyGuid = Guid.Parse(ratyId);
using (DataConnection conn = new DataConnection())
{
var ratyItem = conn.Get<Results>().Where(r => r.RatyId == ratyGuid).SingleOrDefault();
if (ratyItem != null)
{
ratyItem.Count += 1;
ratyItem.TotalValue = ratyItem.TotalValue + decimal.Parse(score, System.Globalization.CultureInfo.InvariantCulture);
conn.Update<Results>(ratyItem);
}
else
{
ratyItem = conn.CreateNew<Results>();
ratyItem.RatyId = ratyGuid;
ratyItem.Count = 1;
ratyItem.TotalValue = decimal.Parse(score, System.Globalization.CultureInfo.InvariantCulture);
conn.Add<Results>(ratyItem);
}
JavaScriptSerializer serializer = new JavaScriptSerializer();
var data = new { TotalValue = ratyItem.TotalValue, Count = ratyItem.Count };
SetCookie(ratyId);
return serializer.Serialize(data);
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
using (DataConnection Data = new DataConnection())
{
StringBuilder sb = new StringBuilder();
var categories = Data.Get<My.Sale.Category>().Where(t => t.Parent == Guid.Empty).ToList();
RecursiveCategory(categories, ref sb);
Literal1.Text = sb.ToString();
}
}
示例12: DeletePost
public bool DeletePost()
{
foreach (PublicationScope scope in Enum.GetValues(typeof (PublicationScope)))
{
using (var connection = new DataConnection(scope))
{
IQueryable<Entries> entries = connection.Get<Entries>().Where(predicate);
connection.Delete<Entries>(entries);
}
}
return true;
}
示例13: GetContent
public IEnumerable<Server.Content> GetContent()
{
using (var connection = new DataConnection())
{
var groupNameMapper = connection.Get<MagazineGroup>().ToDictionary(key => key.Id, value => string.IsNullOrEmpty(value.Name) ? value.Id.ToString() : value.Name);
foreach (var item in connection.Get<MagazineArticle>().OrderByDescending(f => f.Date))
{
yield return
new Content
{
Id = item.Id.ToString(),
GroupName = groupNameMapper[item.Group],
Title = item.Title,
SubTitle = item.SubTitle,
ImageId = item.Image,
Description = item.Html
};
}
}
}
示例14: DeleteProduct
// Deleting a new product
public void DeleteProduct(Guid id)
{
using (var c = new DataConnection())
{
var product = c.Get<Product>().FirstOrDefault(p => p.Id == id);
if (product != null)
{
c.Delete(product);
}
}
}
示例15: DeleteOldBrokenLinks
/// <summary>
/// Delete old broken links
/// </summary>
public static void DeleteOldBrokenLinks()
{
using (var conn = new DataConnection())
{
var items = conn.Get<BrokenLink>().Where(el => el.Date.Value.AddDays(15) < DateTime.Now).ToList();
if (items.Any())
{
Log.LogInformation("Composite.Tools.LegacyUrlHandler.DeleteOldBrokenLinks", String.Format("Deleted {0} items", items.Count));
conn.Delete<BrokenLink>(items);
}
}
}