本文整理汇总了C#中EntitySet.First方法的典型用法代码示例。如果您正苦于以下问题:C# EntitySet.First方法的具体用法?C# EntitySet.First怎么用?C# EntitySet.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntitySet
的用法示例。
在下文中一共展示了EntitySet.First方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public void Save()
{
var es = new EntitySet<sysAppConfig>();
es.Query("select * from sysAppConfig with(nolock) where UserId=:UserId", Session.UserInfo.UserId);
sysAppConfig entity = null;
if (es.Count <= 0)
{
entity = es.AddNew();
entity.Iden = IdenGenerator.NewIden(entity.TableName);
}
else
entity = es.First();
entity.UserId = Session.UserInfo.UserId;
entity.AppConfig = XmlSerializerHelper.Serialize<AppConfig>(this);
es.SaveChanges();
}
示例2: ReCreateMenuParam
private void ReCreateMenuParam()
{
var sql = @"
SELECT FileName=b.Name,a.ClassName
FROM dbo.sysBusinessView a WITH(NOLOCK)
LEFT JOIN dbo.sysFile b WITH(NOLOCK) ON a.FileId=b.Iden
WHERE a.Iden=:Iden";
var viewId = this.ViewModel.MainEntitySet.CurrentEntity.BusinessViewId;
var esView = new EntitySet<QueryEntity>();
esView.Query(sql,viewId);
if (esView.IsEmpty()) return;
var entity = esView.First();
var fileName = entity.GetFieldValue<string>("FileName");
if (fileName.IsEmpty()) return;
var typeName = entity.GetFieldValue<string>("ClassName");
if (typeName.IsEmpty()) return;
var dllFile = Path.Combine(Application.StartupPath, fileName);
if (!File.Exists(dllFile)) return;
AppDomain ad = AppDomain.CreateDomain("sysMenuView Test DLL Marked ViewParameterAttribute");
try
{
LoadAssemblyProxyObject obj = (LoadAssemblyProxyObject)ad.CreateInstanceFromAndUnwrap(LoadAssemblyProxyObject.AssemblyFileName, LoadAssemblyProxyObject.ProxyObjectTypeName);
if (!Path.GetExtension(fileName).Equals(".dll", StringComparison.InvariantCultureIgnoreCase)
&& !Path.GetExtension(fileName).Equals(".exe", StringComparison.InvariantCultureIgnoreCase)) return;
obj.LoadAssembly(dllFile);
var types = obj.GetType(typeName);
if (types == null) return;
var list = types.GetAllPropertyMarked<ViewParameterAttribute>();
if (list.IsEmpty()) return;
var deleteList = this.ViewModel.MenuParamEntitySet.Where(p => !p.Name.In(list.Select(x => x.Name)));
foreach (var item in deleteList)
{
item.Delete();
}
foreach (var item in list)
{
var attr = item.GetCustomAttribute<ViewParameterAttribute>();
var param = this.ViewModel.MenuParamEntitySet.FirstOrDefault(p => p.Name == item.Name);
if (param == null)
{
param = this.ViewModel.MenuParamEntitySet.AddNew();
param.Iden = IdenGenerator.NewIden(param.IdenGroup);
param.MenuId = this.ViewModel.MainEntitySet.CurrentEntity.Iden;
param.Value = string.Empty;
}
param.Name = item.Name;
param.ControlType = (int)attr.ControlType;
param.Description = attr.Desctiption;
param.Category = attr.Category;
}
this.grvParams.RefreshData();
this.grvParams.BestFitColumns();
}
finally
{
AppDomain.Unload(ad);
}
}