本文整理汇总了C#中DBContext类的典型用法代码示例。如果您正苦于以下问题:C# DBContext类的具体用法?C# DBContext怎么用?C# DBContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBContext类属于命名空间,在下文中一共展示了DBContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VerificarUsuario
public static Usuario VerificarUsuario(string password, int user)
{
try
{
var usuario = new Usuario();
using (DBContext db = new DBContext())
{
var check = Encrypt(password);
var pass = Decrypt(password);
var query = from u in db.Usuario
where u.idUsuario == user && u.senhaUsuario == pass
select u;
foreach (Usuario u in query)
{
usuario = u;
}
}
return usuario;
}
catch (Exception)
{
return null;
}
}
开发者ID:elSilveira,项目名称:iaziServerWeb,代码行数:25,代码来源:Simple.cs
示例2: Aggregate
public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
{
//if (graphDBType.IsAbstract)
//{
// #region For abstract types, count all attribute idx of the subtypes
// UInt64 count = 0;
// foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(graphDBType, false))
// {
// if (!aSubType.IsAbstract)
// {
// count += aSubType.GetUUIDIndex(dbContext.DBTypeManager).GetValueCount();
// }
// }
// return new Exceptional<IObject>(new DBUInt64(count));
// #endregion
//}
//else
//{
#region Return the count of idx values
var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);
return new Exceptional<IObject>(new DBUInt64(attributeIndex.GetValueCount()));
#endregion
//}
}
开发者ID:TheByte,项目名称:sones,代码行数:31,代码来源:CountAggregate.cs
示例3: VerificarUsuarioBomo
public static BomoUsuario VerificarUsuarioBomo(string password, string user)
{
try
{
var usuario = new BomoUsuario();
DBContext db = new DBContext();
//var check = Encrypt(password);
var pass = Encrypt(password);
var query = from u in db.BomoUsuario
where u.bomoCliente.email == user && u.senha == pass
select u;
foreach (BomoUsuario u in query)
{
usuario = u;
}
return usuario;
}
catch (Exception)
{
return null;
}
}
开发者ID:elSilveira,项目名称:iaziServerWeb,代码行数:25,代码来源:Simple.cs
示例4: AddBulletin
public ActionResult AddBulletin(string packageid, FormCollection form)
{
SetMenuSelection("Apps");
if (Session["UserID"] == null)
return RedirectToAction("Login", "Home");
DBContext db = new DBContext();
ViewData["PackageID"] = packageid;
if (form.Count > 0)
{
//create
if (form["txtCreateTitle"] == string.Empty)
{
ViewData["CreateStatus"] = "Title is required";
return View();
}
MetrixBulletinBoardAnnouncement mbba = new MetrixBulletinBoardAnnouncement();
mbba.Message = form["editorCreate"];
mbba.PackageID = packageid;
mbba.Title = form["txtCreateTitle"];
db.MetrixBulletinBoardAnnouncements.InsertOnSubmit(mbba);
db.SubmitChanges();
Response.Redirect("/Apps/Bulletin/" + packageid);
}
return View();
}
开发者ID:Arcticus,项目名称:Metrix-webOS-Analytics,代码行数:31,代码来源:AppsController.cs
示例5: IndexSingleOperation
public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
{
IndexKey lookup = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);
var result = myIndex.Contains(lookup, currentType, dbContext);
if (result.Value)
{
var interestingUUIDs = myIndex.GetValues(lookup, currentType, dbContext);
foreach (var aIndexValue in myIndex.GetAllValues(currentType, dbContext))
{
foreach (var aUUID in aIndexValue)
{
if (!interestingUUIDs.Contains(aUUID))
{
yield return aUUID;
}
}
}
}
else
{
foreach (var aIndexValue in myIndex.GetKeyValues(currentType, dbContext).Select(kv => kv.Value))
{
foreach (var aUUID in aIndexValue)
{
yield return aUUID;
}
}
}
yield break;
}
开发者ID:Vadi,项目名称:sones,代码行数:34,代码来源:NotInOperator.cs
示例6: Aggregate
public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
{
if (attributeIndex is UUIDIndex)
{
return new Exceptional<IObject>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true), "Aggregating attribute UUID is not implemented!"));
}
else
{
var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);
// HACK: rewrite as soon as we have real attribute index keys
if (attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.Count != 1)
{
return new Exceptional<IObject>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
}
var typeAttr = graphDBType.GetTypeAttributeByUUID(attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.First());
ADBBaseObject oneVal = typeAttr.GetADBBaseObjectType(dbContext.DBTypeManager);
return new Exceptional<IObject>(attributeIndex.GetKeyValues(indexRelatedType, dbContext).AsParallel().Select(kv =>
{
var mul = oneVal.Clone(kv.Key);
mul.Mul(oneVal.Clone(kv.Value.Count()));
return mul;
}).Aggregate(oneVal.Clone(), (elem, result) => { result.Add(elem); return result; }));
}
}
开发者ID:TheByte,项目名称:sones,代码行数:28,代码来源:SumAggregate.cs
示例7: Aggregate
public override Exceptional<FuncParameter> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
{
var aggregateResult = new DBDouble(0d);
var total = 0UL;
foreach (var dbo in myDBObjects)
{
var attr = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
if (attr.Failed())
{
return new Exceptional<FuncParameter>(attr);
}
if (attr.Value != null && attr.Value is ADBBaseObject && aggregateResult.IsValidValue((attr.Value as ADBBaseObject).Value))
{
aggregateResult.Add((attr.Value as ADBBaseObject));
total++;
}
else
{
return new Exceptional<FuncParameter>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
}
}
aggregateResult.Div(new DBUInt64(total));
return new Exceptional<FuncParameter>(new FuncParameter(aggregateResult));
}
开发者ID:Vadi,项目名称:sones,代码行数:26,代码来源:AvgAggregate.cs
示例8: About
public ActionResult About()
{
AboutListViewModel aboutListViewModel = new AboutListViewModel();
//add AboutViewModel
List<AboutViewModel> listAVM = new List<AboutViewModel>();
List<About> listAbout = new DBContext().Abouts.Where(a => a.IsDelete != true).OrderBy(a => a.Id).ToList();
AboutViewModel AboutViewModel;
foreach (var item in listAbout)
{
AboutViewModel = new AboutViewModel();
AboutViewModel.Title = item.Title;
AboutViewModel.Content = item.content;
AboutViewModel.Thumbnail = item.Thumbnails;
listAVM.Add(AboutViewModel);
}
aboutListViewModel.listAboutViewModel = listAVM;
//Add Welcome
Welcome welcome = new DBContext().Welcomes.Where(w => w.IsDelete != null).FirstOrDefault();
if (welcome != null)
{
aboutListViewModel.WelcomeTitle = welcome.Title;
aboutListViewModel.WelcomeContext = welcome.Content;
aboutListViewModel.WelcomeBackground = welcome.Background;
aboutListViewModel.WelcomeLinkVideo = welcome.LinkVideo;
}
return View(aboutListViewModel);
}
开发者ID:Gobackhome,项目名称:lengkeng,代码行数:29,代码来源:HomeController.cs
示例9: IndexOperation
public override IEnumerable<ObjectUUID> IndexOperation(AAttributeIndex myIndex, TupleDefinition myTuple, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
{
if (myTuple.Count() != 2)
{
throw new GraphDBException(new Error_InvalidInRangeInterval(2, myTuple.Count()));
}
var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);
#region As soon as the index supports ranges use them!!
//limits
var fromKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(0).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
var toKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(1).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
switch (myTuple.KindOfTuple)
{
case KindOfTuple.Inclusive:
return myIndex.InRange(fromKey, toKey, true, true, currentType, dbContext);
case KindOfTuple.LeftExclusive:
return myIndex.InRange(fromKey, toKey, false, true, currentType, dbContext);
case KindOfTuple.RightExclusive:
return myIndex.InRange(fromKey, toKey, true, false, currentType, dbContext);
case KindOfTuple.Exclusive:
return myIndex.InRange(fromKey, toKey, false, false, currentType, dbContext);
default:
throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
}
#endregion
}
开发者ID:TheByte,项目名称:sones,代码行数:31,代码来源:InRangeOperator.cs
示例10: Get
public async Task<IEnumerable<CvViewModel>> Get()
{
List<CvViewModel> cvs = new List<CvViewModel>();
DirectoryInfo photoFolder = new DirectoryInfo(this.workingFolder);
var db = new DBContext();
var cvList = new List<CvViewModel>();
await Task.Factory.StartNew(() =>
{
cvs = photoFolder.EnumerateFiles()
.Where(fi => new[] { ".doc", ".pdf", ".docx", ".txt", ".rtf", ".odt" }.Contains(fi.Extension.ToLower()))
.Select(fi => new CvViewModel
{
Name = fi.Name,
Created = fi.CreationTime,
Modified = fi.LastWriteTime,
Size = fi.Length / 1024
})
.ToList();
foreach (var item in cvs)
{
// TODO check if Resume is deleted
var resume = db.CVs.FirstOrDefault(f => f.Name.Equals(item.Name, StringComparison.InvariantCultureIgnoreCase));
if (resume!= null)
{
item.Id = resume.Guid;
cvList.Add(item);
}
}
});
return cvList;
}
开发者ID:flyeven,项目名称:AngJobs,代码行数:35,代码来源:LocalCvManager.cs
示例11: Import
public override QueryResult Import(IEnumerable<String> myLines, IGraphDBSession myIGraphDBSession, DBContext myDBContext, UInt32 parallelTasks = 1, IEnumerable<String> comments = null, ulong? offset = null, ulong? limit = null, VerbosityTypes verbosityTypes = VerbosityTypes.Errors)
{
var gqlQuery = new GraphQLQuery(myDBContext.DBPluginManager);
#region Evaluate Limit and Offset
if (offset != null)
{
myLines = myLines.SkipULong(offset.Value);
}
if (limit != null)
{
myLines = myLines.TakeULong(limit.Value);
}
#endregion
var queryResult = new QueryResult();
#region Import queries
if (parallelTasks > 1)
{
queryResult = ExecuteAsParallel(myLines, myIGraphDBSession, gqlQuery, verbosityTypes, parallelTasks, comments);
}
else
{
queryResult = ExecuteAsSingleThread(myLines, myIGraphDBSession, gqlQuery, verbosityTypes, comments);
}
#endregion
return queryResult;
}
开发者ID:TheByte,项目名称:sones,代码行数:34,代码来源:GraphDBImport_GQL.cs
示例12: GridView1_GetData
public IQueryable<CompStore.Model.Employee> GridView1_GetData()
{
var db = new DBContext();
IQueryable<CompStore.Model.Employee> result = from b in db.People.OfType<Employee>()
select b;
return result;
}
开发者ID:ugeHidalgo,项目名称:ComputerStoreWF,代码行数:7,代码来源:Employees.aspx.cs
示例13: GetValueForAttribute
/// <summary>
/// <seealso cref=" AAttributeAssignOrUpdate"/>
/// </summary>
public override Exceptional<IObject> GetValueForAttribute(DBObjectStream myDBObject, DBContext myDBContext, GraphDBType myGraphDBType)
{
if (AttributeIDChain.IsUndefinedAttribute)
{
return new Exceptional<IObject>(GraphDBTypeMapper.GetBaseObjectFromCSharpType(Value));
}
#region Simple value
var dbType = AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager);
if (AttributeIDChain.LastAttribute is SpecialTypeAttribute_UUID)
{
dbType = myDBContext.DBTypeManager.GetTypeByName(GraphDBTypeMapper.GetBaseObjectFromCSharpType(Value).ObjectName);//DBString.Name);
}
if (GraphDBTypeMapper.IsAValidAttributeType(dbType, AttributeAssignType, myDBContext, Value))
{
return new Exceptional<IObject>(GraphDBTypeMapper.GetGraphObjectFromType(AttributeAssignType, Value)); ;
}
else
{
return new Exceptional<IObject>(new Error_InvalidAttributeValue(AttributeIDChain.LastAttribute.Name, Value));
}
#endregion
}
开发者ID:Vadi,项目名称:sones,代码行数:28,代码来源:AttributeAssignOrUpdateValue.cs
示例14: Aggregate
public override Exceptional<IObject> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
{
var foundFirstMax = false;
var aggregateResult = myTypeAttribute.GetADBBaseObjectType(myDBContext.DBTypeManager);
foreach (var dbo in myDBObjects)
{
var attrResult = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
if (attrResult.Failed())
{
return attrResult;
}
var attr = attrResult.Value;
if (attr != null && attr is ADBBaseObject && aggregateResult.IsValidValue((attr as ADBBaseObject).Value))
{
if (foundFirstMax == false)
{
aggregateResult.Value = (attr as ADBBaseObject).Value;
foundFirstMax = true;
}
else
{
if (aggregateResult.CompareTo((attr as ADBBaseObject).Value) < 0)
{
aggregateResult.Value = (attr as ADBBaseObject).Value;
}
}
}
else
{
return new Exceptional<IObject>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
}
}
return new Exceptional<IObject>(aggregateResult);
}
开发者ID:TheByte,项目名称:sones,代码行数:35,代码来源:MaxAggregate.cs
示例15: RemoveBackwardEdges
protected Exceptional RemoveBackwardEdges(TypeUUID myTypeUUID, Dictionary<AttributeUUID, object> myUserdefinedAttributes, ObjectUUID myObjectUUIDReference, DBContext myDBContext)
{
#region get type that carries the attributes
var aType = myDBContext.DBTypeManager.GetTypeByUUID(myTypeUUID);
#endregion
#region process attributes
foreach (var aUserDefinedAttribute in myUserdefinedAttributes)
{
#region Data
GraphDBType typeOFAttribute = null;
TypeAttribute attributesOfType = null;
#endregion
#region get GraphType of Attribute
attributesOfType = aType.Attributes[aUserDefinedAttribute.Key];
typeOFAttribute = myDBContext.DBTypeManager.GetTypeByUUID(attributesOfType.DBTypeUUID);
#endregion
IEnumerable<Exceptional<DBObjectStream>> listOfObjects;
if (aUserDefinedAttribute.Value is IReferenceEdge)
{
listOfObjects = ((IReferenceEdge)aUserDefinedAttribute.Value).GetAllEdgeDestinations(myDBContext.DBObjectCache);
}
else
{
listOfObjects = myDBContext.DBObjectCache.LoadListOfDBObjectStreams(typeOFAttribute, (HashSet<ObjectUUID>)aUserDefinedAttribute.Value);
}
foreach (var aDBObject in listOfObjects)
{
if (aDBObject.Failed())
{
return new Exceptional(aDBObject);
}
var removeExcept = myDBContext.DBObjectManager.RemoveBackwardEdge(aDBObject.Value, myTypeUUID, aUserDefinedAttribute.Key, myObjectUUIDReference);
if (removeExcept.Failed())
{
return new Exceptional(removeExcept);
}
}
}
#endregion
return Exceptional.OK;
}
开发者ID:TheByte,项目名称:sones,代码行数:60,代码来源:AAttributeAssignOrUpdateOrRemove.cs
示例16: GetValue
public ADBBaseObject GetValue(GraphDBType myTypeID, TypeAttribute myAttrID, UUID mySettingUUID, DBContext context)
{
if (_TypeAttrSetting.ContainsKey(myTypeID.UUID))
{
if (_TypeAttrSetting[myTypeID.UUID].ContainsKey(myAttrID.UUID))
{
if (_TypeAttrSetting[myTypeID.UUID][myAttrID.UUID].ContainsKey(mySettingUUID))
{
return _TypeAttrSetting[myTypeID.UUID][myAttrID.UUID][mySettingUUID];
}
}
else
{
_TypeAttrSetting[myTypeID.UUID].Add(myAttrID.UUID, new Dictionary<UUID, ADBBaseObject>());
}
}
else
{
_TypeAttrSetting.Add(myTypeID.UUID, new Dictionary<AttributeUUID, Dictionary<UUID, ADBBaseObject>>());
_TypeAttrSetting[myTypeID.UUID].Add(myAttrID.UUID, new Dictionary<UUID, ADBBaseObject>());
}
//we are here, so we have to add the setting and return it
var settingValue = context.DBSettingsManager.GetSettingValue(mySettingUUID, context, TypesSettingScope.ATTRIBUTE, myTypeID, myAttrID).Value.Clone();
_TypeAttrSetting[myTypeID.UUID][myAttrID.UUID].Add(mySettingUUID, settingValue);
return settingValue;
}
开发者ID:TheByte,项目名称:sones,代码行数:30,代码来源:SelectSettingCache.cs
示例17: ExecFunc
public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
{
if (CallingObject != null)
return new Exceptional<FuncParameter>(new FuncParameter(new DBBoolean(true)));
else
return new Exceptional<FuncParameter>(new FuncParameter(new DBBoolean(false)));
}
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:Exists.cs
示例18: ExecFunc
public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
{
if (CallingObject is ADBBaseObject)
return new Exceptional<FuncParameter>(new FuncParameter(new DBString((CallingObject as ADBBaseObject).Value.ToString().ToLower())));
else
return new Exceptional<FuncParameter>(new Errors.Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
}
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:ToLowerFunc.cs
示例19: ExecFunc
public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
{
var pResult = new Exceptional<FuncParameter>();
// The edge we starting of (Friends)
var typeAttribute = CallingAttribute;
// Get the source Objects from the CallingObject, if this is not a reference this function is used in a wrong context and return a error
IEnumerable<ObjectUUID> sourceDBOs = null;
if (CallingObject is IReferenceEdge)
{
sourceDBOs = (CallingObject as ASetOfReferencesEdgeType).GetAllReferenceIDs();
}
else
{
throw new GraphDBException(new Error_InvalidEdgeType(CallingAttribute.EdgeType.GetType(), typeof(ASetOfReferencesEdgeType), typeof(ASingleReferenceEdgeType)));
}
// The destination DBObjects which are passed with the first parameter
var destDBOs = (myParams[0].Value as DBEdge).GetDBObjects();
if (destDBOs == null)
{
throw new GraphDBException(new Error_InvalidEdgeType(CallingAttribute.EdgeType.GetType(), typeof(ASetOfReferencesEdgeType), typeof(ASingleReferenceEdgeType)));
}
// The depth which is passed as the second parameter
Int64 mayDepth = (myParams[1].Value as DBInt64).GetValue();
// Call your own implementation of a path function and return the result, in this case it is a list of DB object (uuids)
var resultOfPathFunction = new List<ObjectUUID>();
pResult.Value = new FuncParameter(new EdgeTypeSetOfReferences(resultOfPathFunction, CallingAttribute.DBTypeUUID));
return pResult;
}
开发者ID:TheByte,项目名称:sones,代码行数:35,代码来源:SimplePathFunc.cs
示例20: DBTypeManager
public DBTypeManager(DBTypeManager dBTypeManager)
{
_DBContext = dBTypeManager._DBContext;
_UserID = dBTypeManager._UserID;
_DatabaseRootPath = dBTypeManager._DatabaseRootPath;
_IGraphFSSession = dBTypeManager._IGraphFSSession;
_ObjectLocationsOfAllUserDefinedDatabaseTypes = dBTypeManager._ObjectLocationsOfAllUserDefinedDatabaseTypes;
_SystemTypes = dBTypeManager._SystemTypes;
_BasicTypes = dBTypeManager._BasicTypes;
_GUIDTypeAttribute = dBTypeManager._GUIDTypeAttribute;
//TODO: As soon as we have serialized Indices we can recomment these sections
#region As soon as we have serialized Indices we can recomment these sections
//_UserDefinedTypes = dBTypeManager._UserDefinedTypes;
//_TypesNameLookUpTable = dBTypeManager._TypesNameLookUpTable;
foreach (GraphDBType ptype in _SystemTypes.Values)
_TypesNameLookUpTable.Add(ptype.Name, ptype);
foreach (GraphDBType ptype in _BasicTypes.Values)
_TypesNameLookUpTable.Add(ptype.Name, ptype);
LoadUserDefinedDatabaseTypes(false);
#endregion
}
开发者ID:ipbi,项目名称:sones,代码行数:28,代码来源:DBTypeManager.cs
注:本文中的DBContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论